Emiko Kezuka wrote: > Let me summarize to check whether I took it correctly. > > I was wrong on the assumption that the variable within > the static method is one and only and used everywhere, > just like the method itself. Isn't it?
Correct. Method local (automatic) variables work the same way whether the method is static or not. > I thought a static method craves no memory of its own, even for its > variables, > for sometimes static methods are called with Class names instead of > instance names and seems to have no instances at all, as David > mentioned... Have you ever programmed in a non-Object Oriented language like FORTRAN, Pascal or C? All the code in any application written in these languages is static and most all require local memory space. So when you declare a method static in Java, all you are really doing is telling the compiler, "this code executes the old-fashioned way." > I did not fully understand about stack thing, but I understood > a static method will assign memory for its "automatic" variables > (variables declared in the method) every time the method is > called anew and release these memory the method was terminated. > So each call of the method has automatic variables independently. Exactly. > Assign memory to the automatic variable by every call is essential > to "reentrant" program and it does nothing with static or not. > > Is my understanding OK this time? By George, you've got it. Tomm To change your membership options, refer to: http://www.sys-con.com/java/list.cfm
