This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
Ok, if I have Class A and it contains 4 static methods. Then lets say I have 4 more Classes, Class B, Class C, Class D, and Class E. Now, if I instantiate Class A in B, C, D, and E is there still only 1 instance of each of the static methods in memory from Class A?
i suppose so because when once u have a static method in a class no matter how many instances of that class u have the method stays the same because it is only loaded once at compile time so i suppose the same would apply for instanciating class a in different class since that static method is in class a alone i suppose it will still stay the same correct me if i am wrong i'll appreciate it ---------------- khella smith
Methods are not replicated per object. Methods are kept in a special "method area" with the Classfile. Some of those methods are tracked as Static and some as member methods. When a method is invoked the JVM ALWAYS goes to the classfile to find the code to execute. It is over in "classfile-land" that polymorphism takes place. The only things that actually reside in an object are the variables that track state and a "type" identifier.
"JavaRanch, where the deer and the Certified play" - David O'Meara