Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

glossywhite

macrumors 65816
Original poster
Feb 28, 2008
1,120
3
Hi all.

Here is a very dull and useless example

Code:
public class myClass{
public [B][COLOR="Red"]static[/COLOR][/B] void main(String args[]){
System.out.println("hello world is dull");
}
}

My question is this - is the keyword "static", defining that "main" is not an instantiated or called from an instantiated class, and therefore it is always static, and therefore always accessible and at a fixed point in memory?.

Thanks.
 
Hi all.

Here is a very dull and useless example

Code:
public class myClass{
public [B][COLOR="Red"]static[/COLOR][/B] void main(String args[]){
System.out.println("hello world is dull");
}
}

My question is this - is the keyword "static", defining that "main" is not an instantiated or called from an instantiated class, and therefore it is always static, and therefore always accessible and at a fixed point in memory?.

Thanks.

"static" in Java means that it is part of the class itself, not of any object. It is always accessible when the class is loaded (and the class will be loaded if you try to access a static method).

And "at a fixed point in memory" is something that is completely meaningless in Java. And when you say "always static", obviously a static thing is always static or do you mean something different with this question?
 
"static" in Java means that it is part of the class itself, not of any object. It is always accessible when the class is loaded (and the class will be loaded if you try to access a static method).

And "at a fixed point in memory" is something that is completely meaningless in Java. And when you say "always static", obviously a static thing is always static or do you mean something different with this question?

Thanks, you've cleared the mental fog, and my bad regarding the ambiguity of my comment on the word static... d'oh! :p
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.