• Post Reply Bookmark Topic Watch Topic
  • New Topic

is Arrays are Object?  RSS feed

 
Thennam Pandian
Ranch Hand
Posts: 163
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
is Array in java are Object?

int a[]=new int[10];

new will allocate memory. but int is a type not an Class ?

please help me.......
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24217
38
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
An array of any type is an Object, yes -- an array is an instance of a special synthetic class that extends, directly or indirectly, java.lang.Object, just like any other class. You can call hashCode(), equals(), toString(), and other Object methods on any array.

The fact that an int[] is a class doesn't mean that "int" is a class -- it's not.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!