Why is the output of this code 111111?

后端 未结 9 1889
星月不相逢
星月不相逢 2021-01-13 20:10

This is the code. I tried to solve it, but I can\'t understand how its output is 111111?

public class Test { 
      public static void main(String[] args) {
         


        
9条回答
  •  挽巷
    挽巷 (楼主)
    2021-01-13 20:46

    As someone posted, your for-loop causes this result (11111). You also mentioned your question be like "It's storing values in to an array?". To my best understanding on your question, it's like you are trying to get the values from an array and store them into an another array. If so, this could be one of the options.

    public static void main(String []args){
            int[] list = {1, 2, 3, 4, 5, 6};
            int[] myList = new int[list.length];
            for (int i=0; i

提交回复
热议问题