aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Arrays - basic question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Arrays - basic question" Watch "Arrays - basic question" New topic
Author

Arrays - basic question

ankur rathi
Ranch Hand

Joined: Oct 11, 2004
Posts: 3830
when we create any array object .
int[] i = new int[3];
the hierarchi is :


is this correct .
thanks .
[ January 31, 2005: Message edited by: rathi ji ]
shandilya popuru
Ranch Hand

Joined: Dec 21, 2004
Posts: 95
hi

i think int[]`s direct super class is lang.Object

this code

int[] s=new int[10];
System.out.println(s.getClass().getSuperclass().toString());

gives java.lang.Object as o/p


sandy
Edwin Dalorzo
Ranch Hand

Joined: Dec 31, 2004
Posts: 961
Hierachy depends if your array is a primitive data type array or a reference type array.

Primitive data types arrays are direct descendants of Object class, but not of Object[].

However reference type arrays are direct descendants of Object[].

So hierachy would be like this for primitive data types


Object
^
byte[] short[] char[] int[] long[] float[] double[] boolean[]

But for reference types:

Object
^
Object[]
^
Integer[] MyClass[] Float[] String[]

Hope it helps!
ankur rathi
Ranch Hand

Joined: Oct 11, 2004
Posts: 3830
thanks Edwin , but what about Arrays class . when it is useful .
thanks a lot .
ankur rathi
Ranch Hand

Joined: Oct 11, 2004
Posts: 3830
Can any body tell me , what is the use of Arrays class .

thanks .
Sumit Deshpande
Ranch Hand

Joined: Jan 10, 2005
Posts: 38
http://java.sun.com/j2se/1.4.2/docs/api/index.html

"This class contains various methods for manipulating arrays (such as sorting and searching)."
Nicholas Cheung
Ranch Hand

Joined: Nov 07, 2003
Posts: 4982
what is the use of Arrays class .


If you are refering to java.util.Arrays, its main usage is to provide utilities (static methods) to manipulate arrays. All of its methods are static (just like java.lang.Math).

Nick


SCJP 1.2, OCP 9i DBA, SCWCD 1.3, SCJP 1.4 (SAI), SCJD 1.4, SCWCD 1.4 (Beta), ICED (IBM 287, IBM 484, IBM 486), SCMAD 1.0 (Beta), SCBCD 1.3, ICSD (IBM 288), ICDBA (IBM 700, IBM 701), SCDJWS, ICSD (IBM 348), OCP 10g DBA (Beta), SCJP 5.0 (Beta), SCJA 1.0 (Beta), MCP(70-270), SCBCD 5.0 (Beta), SCJP 6.0, SCEA for JEE5 (in progress)
ankur rathi
Ranch Hand

Joined: Oct 11, 2004
Posts: 3830
Thanks Nick ,
I got the point . Actually I was thinking that every array is implicitly sub class of Arrays class . But this is not the case , primitives array extends from Object class ( as every other class extends ) & reference variable array extends from Object[] class & that extends Object class . And Arrays class provides static methods for manuprlatings this arrays .

Thanks once again to all .
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Arrays - basic question