• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

class name of java arrays

 
Chris Wox
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
int[] a = new int[4];

the above line is declaring and instantiating an array object .

Could someon please tell me what is the class name of the above object ?
since as i understand every object in java is an instance of the class .
 
Keith Lynn
Ranch Hand
Posts: 2409
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The name is [I

You can find the name of an object like this.


[ June 15, 2006: Message edited by: Keith Lynn ]
 
Chris Wox
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks for the reply

but now i have another question

in the code getClass().getName()

getClass() is a method in the object class which Returns the runtime class of an object

but i couldnt find anything about getName(), is it also a method in Object class ?
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65126
92
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Think about it for a moment. If getClass() returns an instance of Class, then which object is the getName() operating upon? The original Object instance, or the returned Class instance?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic