This week's book giveaway is in the OCAJP 8 forum.
We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes class name of java arrays Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of OCA Java SE 8 Programmer I Study Guide this week in the OCAJP 8 forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "class name of java arrays " Watch "class name of java arrays " New topic

class name of java arrays

Chris Wox
Ranch Hand

Joined: May 25, 2006
Posts: 34
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

Joined: Feb 07, 2005
Posts: 2367
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

Joined: May 25, 2006
Posts: 34
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

Joined: Jan 10, 2002
Posts: 63350

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?

[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
I agree. Here's the link:
subject: class name of java arrays
It's not a secret anymore!