Array initialisation in java

前端 未结 5 1936
忘掉有多难
忘掉有多难 2020-12-01 23:20

I noticed one could write code like this, which is perfectly normal, by the way:

int arrays[] = {1, 2, 3};
for (int n : arrays)
   System.out.println(n);
         


        
5条回答
  •  时光说笑
    2020-12-02 00:12

    To be honest, the only fallacy I see in your explanation is how can you tell a computer to go through an object/memory that does not exist?

    You have to create something to let go through it first, here, you have created nothing and the logical fallacy exists in your head because you have thought more deep than the creation rules of Java itself.

    Don't worry, I find myself in situations like you but the most important thing is to learn how Java was programmed first!

提交回复
热议问题