Mega Code Archive

 
Categories / Java Tutorial / Collections
 

Arrays of Objects

Arrays of Objects only stores references to the actual objects, and initially each reference is null unless explicitly initialized. public class MainClass {   public static void main (String args[]) {     int array1[] = {1, 2, 3, 4, 5};     for(int i: array1){       System.out.println(i);            }   } } 1 2 3 4 5