My professor said that whenever I use a static method from a class, the whole class is loaded into memory And then the method is executed.
My question is if there are 100 ways and 50 different variables in a class and if I were called a stable method from that class. The entire class (100 methods and 50 variables) is loaded into memory, how does java disabled in case of memory and performance deal with this kind of problem?
This is true, when you call a still , the class Byte-code is loaded (but not once , every time ). This also happens when you call a non-static method. In the latter case, an example should also be made. Thus, in the meaning of your question, it is a wrong contradiction. Because java is a dynamic language and platform (with a JIT) Runtime capability can increase significantly between method invocations, thus writing is clear and short code (it is) best. If there is a clear way to implement your solution, use stable methods.
No comments:
Post a Comment