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.
But in Java 5 version there is a facility like ArrayList also could hold only primitive data types if we declare like following:

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:
class java.lang.Object.

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?
2) Hass list

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:

Do you have a Java Problem?
Ask It in The Java Forum

Java Books
Java Certification, Programming, JavaBean and Object Oriented Reference Books

Return to : Java Programming Hints and Tips

All the site contents are Copyright © www.erpgreat.com and the content authors. All rights reserved.
All product names are trademarks of their respective companies.
The site www.erpgreat.com is not affiliated with or endorsed by any company listed at this site.
Every effort is made to ensure the content integrity.  Information used on this site is at your own risk.
 The content on this site may not be reproduced or redistributed without the express written permission of
www.erpgreat.com or the content authors.