Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

jdk1.4 way of doing Class.getCanonicalName()?

Status
Not open for further replies.

carpeliam

Programmer
Mar 17, 2000
990
US
Class.getName() doesn't work for me because for a class type like "char[]" it returns something unreadable like "[C". Is there a way to return the class type in a readable fashion no matter what type of Class it is?

Liam Morley
lmorley@wpi.edu
"light the deep, and bring silence to the world.
light the world, and bring depth to the silence."
 
it is. the following code prints "true":<BR><DIV id="code"><h4>CODE</h4><div class="body">char[] myCharArray = new char[0];<BR>System.out.println(myCharArray.getClass().equals(char[].class));</DIV></DIV> <p>Liam Morley<br><A HREF="mailto:"></A><br>&quot;light the deep, and bring silence to the world.<br>light the world, and bring depth to the silence.&quot;
 
Liam, not quite following your requirement here ... the 'name' of a char[] object is '[C', for int[] object it is '[I', for long[], '[J' and so on. These are the "human readable class names" for these array objects.

--------------------------------------------------
Free Database Connection Pooling Software
 
This is for an Eclipse plug-in and I wanted to be consistent with their UI.<BR><BR>It may be a moot point in any case as we might not be using java.lang.Class (Eclipse has two whole packages of its own brand of type heirarchies). But if anybody knows of some method that gives back "char[]", I'm still interested. <p>Liam Morley<br><A HREF="mailto:"></A><br>&quot;light the deep, and bring silence to the world.<br>light the world, and bring depth to the silence.&quot;
 
Well I would write a wrapper if you really need to get 'char[]' when the classname is '[C' ...

--------------------------------------------------
Free Database Connection Pooling Software
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top