File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes static class variable Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "static class variable" Watch "static class variable" New topic

static class variable

amit sanghai
Ranch Hand

Joined: Dec 05, 2000
Posts: 231
I have seen some people use implicit static "class" variable to get the name of a class.
if class name is Demo , then what is "Demo.class"
Roger Goerke

Joined: Sep 16, 2002
Posts: 9
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.

Yes. Shrubberies are my trade. I am a shrubber. <br />My name is 'Roger the Shrubber'.<br />I arrange, design, and sell shrubberies.
amit sanghai
Ranch Hand

Joined: Dec 05, 2000
Posts: 231
Is this specific to SUN JVM, because there is nothing mentioned about .class in the Java API.
Ilja Preuss

Joined: Jul 11, 2001
Posts: 14112
No, class literals are part of the language specification:

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
I agree. Here's the link:
subject: static class variable
It's not a secret anymore!