i know public static void method() is called because it 's an entry point for compiler.
1) compiler uses the name of class inside which main method is present,
& compiler will call main method with class name.it's fine.( ClassName.main()) Make sure that you understand the difference between
compile time and
runtime. Your program does not have an "entry point for the compiler". As far as the
compiler is concerned, the method public static void main(
String[] args) is just a method like any other method. For the
Java runtime environment, the main(...) method is the entry point of your program - that's where the runtime environment starts running your program.
but till that time Obect of Class or Reference of that class is not created in memory. so how static method technically call. becz obj is not in memory at the time of execution.how compiler will play with it at runtime.
will it create obj of that class or some thing other ?
how compiler will allocate space & where it will store Static Method & Variable.??? The compiler doesn't have anything to do with runtime. You use the compiler to convert your Java source code to bytecode (in a class file), which you do before runtime.
Static method and variables are at the class level, not at the object level. You don't need an object to execute a static method. The static member variables of a class are stored somewhere in memory, but exactly how depends on the implementation details of the JVM. There's no object necessary to store them.