Win a copy of Learn Spring Security (video course) this week in the Spring forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Class litral ??

 
R K Singh
Ranch Hand
Posts: 5384
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
From JLS:
Names of types are used in declarations, casts, class instance creation expressions, array creation expressions, class literals, and instanceof operator expressions.
---------------------------------------------------------------
What is class litral?
------------------
Regards
Ravish
 
Marilyn de Queiroz
Sheriff
Posts: 9059
12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Double.class
Object.class
Class.class
 
Vikrama Sanjeeva
Ranch Hand
Posts: 760
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
U mean Double.class is from wrapper class Double & so on.?
Bye
Viki.
------------------
Count the flowers of ur garden,NOT the leafs which falls away!
 
Rosie Nelson
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A class literal is an expression consisting of the name of a class, interface, array, or primitive type followed by a `.' and the token class. It evaluates to an object of type Class, the class object for the named type (or for void).
For reference types, a class literal is equivalent to a call to Class.forName with the appropriate string, except that it does not raise any checked exceptions. (Its efficiency is likely to be comparable to that of a field access, rather than a method call.) The class literal of a reference type can raise NoClassDefFoundError, in much the same way that a class variable reference can raise that error if the variable's class is not available.
The class literal of a primitive type or void is equivalent to a static variable reference to a pre-installed primitive type descriptor, according to this table:
boolean.class == Boolean.TYPE
char.class == Character.TYPE
byte.class == Byte.TYPE
short.class == Short.TYPE
int.class == Integer.TYPE
long.class == Long.TYPE
float.class == Float.TYPE
double.class == Double.TYPE
void.class == Void.TYPE


 
R K Singh
Ranch Hand
Posts: 5384
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Rosie Nelson
can you tell me the source from where you get this knowledge ??
Thanks in advance.
------------------
Regards
Ravish
 
Valentin Crettaz
Gold Digger
Sheriff
Posts: 7610
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
JLS 15.8.2
In the API
look at java.lang.Integer in the Field Section. You have

static Class TYPE
The Class object representing the primitive type int.

And the same goes for the other wrapper classes.
HIH

------------------
Valentin Crettaz
Sun Certified Programmer for Java 2 Platform
 
R K Singh
Ranch Hand
Posts: 5384
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Valentin
Now another:
the class object for the named type (or for void).
does Java support void ??
------------------
Regards
Ravish
 
Valentin Crettaz
Gold Digger
Sheriff
Posts: 7610
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
java.lang.Void.
What do you mean by does Java support void ?
HIH
------------------
Valentin Crettaz
Sun Certified Programmer for Java 2 Platform
 
R K Singh
Ranch Hand
Posts: 5384
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Valetin
I have to dig more
now agian going to hibernate... will come back soon... but I do check this forum though I do not reply or post que.(Last week I controlled a lot.... )
Actually I read some where that you can not cast any thing to void like we do in 'C'.....
will be back

------------------
Regards
Ravish
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic