| Author |
how to get Class of primitive datatypes array . Class.forName(int[]) throws exception
|
Aruna Agrawal
Ranch Hand
Joined: Jan 27, 2005
Posts: 66
|
|
hi all Class.forName(int[]) throws exception ClassNotFound Exception. I need to Class instance of primitive types . How do i do it?
|
 |
David O'Meara
Rancher
Joined: Mar 06, 2001
Posts: 13459
|
|
Try int[].class Dave
|
[ JavaRanch FAQ ][ Book Promotions ][ DbTamer ][ BumperStickers ][ JavaRanch Badges ]
|
 |
Nischal Topno
Ranch Hand
Joined: Nov 24, 2001
Posts: 45
|
|
|
primitives is not an object, hence you cannot get a class from int. If you looking at primitve wrappers then it's the Integer class that you require.
|
 |
David O'Meara
Rancher
Joined: Mar 06, 2001
Posts: 13459
|
|
Interestingly, it looks like this may also work, but confuse the heck out of anyone who has to support it:
|
 |
Aruna Agrawal
Ranch Hand
Joined: Jan 27, 2005
Posts: 66
|
|
Thanks .. [B for byte array [I for int array [F for float array etc works fine
|
 |
Ilja Preuss
author
Sheriff
Joined: Jul 11, 2001
Posts: 14112
|
|
|
int[].class didn't work?
|
The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
|
 |
David O'Meara
Rancher
Joined: Mar 06, 2001
Posts: 13459
|
|
I really recommend using int[], I really do. Anyone looking at the code after this won't have any idea what "[I" is. They may even slap you in the street
|
 |
 |
|
|
subject: how to get Class of primitive datatypes array . Class.forName(int[]) throws exception
|
|
|