The only kind of "static class" is a nested class marked "static", and in fact these are extremely similar to normal top-level classes. A nested class that's not marked static is associated with one specific instance of the containing class; a static nested class is not. That's the only difference.
As far as classloaders go: a JVM almost always has more than one ClassLoader; at the very least, there's generally one that loads the "system classes" (the java.* classes and such that are "built in") and another ClassLoader than loads your classes.
The very first ClassLoader is assembled "by hand" by the JVM. Ultimately a class is just a data structure inside the running JVM program; the first couple of classes in a running JVM are put together just by initializing those data structures to "bootstrap" the class loading process.
the Jvm works regardless of whether a method is static od nonstatic.
Hmmm. You might need to give this some thought first.
A static member variable can be referenced without an instance because the value is stored outside of any instance; an instance variable is stored in an instance of the class, so without an instance to reference, there is no variable.
For methods, in a way, that's true; the code doesn't live in each instance, there's just one copy of a method's code tht covers the whole class. But the implicit first argument of an instqnce method is an instance of that class, and since many instance methods operate on instance data, without an instance to operate on, the method wouldn't be able to work. The only instance methods that could be called without an instance (in theory) are those that don't refer to the instance at all -- such methods could have a "static" declaration added to them, and still compile.
Joined: Oct 21, 2007
sorry but one last thing!!
By loading a class means the class loader puts the byte code present in the .class file in memory ?
By instantiating a class means calling the constructor?
author and iconoclast
1) Yes, pretty much. Loading the bytecode, creating space to hold the static members, initializing them, etc (technically, loading the bytecode and initializing the static data are two separate things, and one can happen before the other -- but in practice we generally talk about them both together.)
2) Allocating a block of memory to hold the object's instance variables, and then calling the constructor, yes. Java's "new" operator does both of these things.
Joined: Oct 21, 2007
thanks!.. this has cleared a lot of doubts i had...