Quantcast
Channel: Programming Forums
Viewing all articles
Browse latest Browse all 51036

Question about outputting array list

$
0
0
Public class test {
    public static void main(String[] args){
      int[] result = new int[5];
        
        for (int i = 0; i < result.length; i++){
                result[i] = i;
        }
        for (int value : result){
                System.out.print (value);
        }
    }
}



I was wondering why is for needed with (int value : result) to print out to the console the array list properly. The output would be

0 1 2


but if we take out the for (int value : result) and just put System.out.print (result), the output would be
[I@19189e1.

Viewing all articles
Browse latest Browse all 51036

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>