Only 48 hours left in the trailboss' kickstarter!

New rewards and stretch goals. CLICK HERE!



  • Post Reply Bookmark Topic Watch Topic
  • New Topic

static class variable  RSS feed

 
amit sanghai
Ranch Hand
Posts: 231
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have seen some people use implicit static "class" variable to get the name of a class.
eg.
if class name is Demo , then what is "Demo.class"
 
Roger Goerke
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Demo.class is a java.lang.Class object. It's name is Demo. If you toString() it you will get
class <package>Demo
For each defined Java class in a JVM there is one (and only one) Class object.
 
amit sanghai
Ranch Hand
Posts: 231
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is this specific to SUN JVM, because there is nothing mentioned about .class in the Java API.
 
Ilja Preuss
author
Sheriff
Posts: 14112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No, class literals are part of the language specification:
http://java.sun.com/docs/books/jls/second_edition/html/expressions.doc.html#251530
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!