This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Arrays - basic question

 
ankur rathi
Ranch Hand
Posts: 3830
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 95
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Edwin Dalorzo
Ranch Hand
Posts: 961
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3830
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks Edwin , but what about Arrays class . when it is useful .
thanks a lot .
 
ankur rathi
Ranch Hand
Posts: 3830
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can any body tell me , what is the use of Arrays class .

thanks .
 
Sumit Deshpande
Ranch Hand
Posts: 38
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 4982
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
ankur rathi
Ranch Hand
Posts: 3830
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic