Whether Primitive
Data Type Arrays, can be considered as objects
I'm a bit confused, whether primitive data type arrays, can be considered as objects? I think the ArrayList in the collection framework only
suppose to hold objects. I am not sure for Arrays.
ArrayList <Integer> mylist=new ArrayList<Integer>() Kutti Barani An array is an Object in Java. This is true irrespective of its compenent type. The component type of an array may be a primitive type or Object type it does not matter. You may be surprised to know that the super class of an array is the Object class. try running this: int[] ai = new int[1]; System.out.println(ai.getClass().getSuperclass()); You should see the output as:
This is convincing enouh to say that every array is an object, even if its component type is primitive. Vinay Binny 1) Difference between ArrayList & vector?
First Both are growable array of objects. Vector is synchronized(bydefault) ArrayList not(if you want Collection.SynchronizedList(list c)) Vector is only growing .but arraylist is shrinking and growing. Sanakr
Related:
Ask It in The Java Forum Java Books
Return to : Java Programming Hints and Tips All the site contents are Copyright © www.erpgreat.com
and the content authors. All rights reserved.
|