File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Help needed with class literal Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Help needed with class literal" Watch "Help needed with class literal" New topic
Author

Help needed with class literal

Ranjitha Serginaro
Greenhorn

Joined: Jan 10, 2013
Posts: 2
I was going through literals in javadocs where i came across this sentence "Finally, there's also a special kind of literal called a class literal, formed by taking a type name and appending ".class"; for example, String.class. This refers to the object (of type Class) that represents the type itself." which doesn't make any sense to me even though i paid attention to all the other topics prior to this. If any one could explain with examples or references it would be greatly appreciated. The link to the javadocs page displaying this is below.
http://docs.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 29249
    
139

You can write without having to use the new operator. This is true for the class object too.

No "new" to be found in that code. The Class class isn't used much until you do more advanced Java like reflection. At which point, it is used for Reflection to look up methods/fields on the Class.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Help needed with class literal
 
Similar Threads
What is null ?
Primatives and Literals
A question on reflection
sort problem
Object extends Object