Is there a performance difference between a for loop and a for-each loop?

前端 未结 16 1566
清歌不尽
清歌不尽 2020-11-22 10:38

What, if any, is the performance difference between the following two loops?

for (Object o: objectArrayList) {
    o.DoSomething();
}

and <

16条回答
  •  情书的邮戳
    2020-11-22 11:02

    public class FirstJavaProgram {
    
        public static void main(String[] args) 
        {
            int a[]={1,2,3,45,6,6};
    
    // Method 1: this is simple way to print array 
    
            for(int i=0;i

提交回复
热议问题