1 2 Previous Next 15 Replies Latest reply: Apr 11, 2006 1:25 PM by 807592 Go to original post RSS
      • 15. Re: Use of an ArrayList
        807592
        1) please start your own thread.

        2) println can print Lists of objects but not lists of primatives. To see the difference, compare the attempt to print a List of ints (primatives) vs. a list of Integers (objects):
        import java.util.Arrays;
        import java.util.List;
        
        public class Fubar
        {
            public static void main(String[] args)
            {
                int[] intArray = {1, 2, 3, 4, 5};
                Integer[] integerArray = {1, 2, 3, 4, 5}; //autoboxing
                
                List intList = Arrays.asList(intArray);
                List<Integer> integerList = Arrays.asList(integerArray);
                
                System.out.println(intList);
                System.out.println(integerList);
            }
        }
        For this to work, the objects in the list need to have a viable override of the toString method.
        1 2 Previous Next