File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes difference between static local variables and static global variables. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "difference between static local variables and static global variables." Watch "difference between static local variables and static global variables." New topic
Author

difference between static local variables and static global variables.

bharadwaz reddy
Greenhorn

Joined: Jul 08, 2009
Posts: 4
hello,

please somebody explain me,the difference between static local variable and static global variable. with example programs.
Sachin Adat
Ranch Hand

Joined: Sep 03, 2007
Posts: 213
How did you come arrive at this question.............
I've never heard anything about static local variable


SCJP 6
How To Ask Questions On Java Ranch - How To Answer Questions On Java Ranch
Aurelian Tutuianu
Ranch Hand

Joined: May 13, 2004
Posts: 86
This is a C question, not a Java one.
In Java the state is carried out by class instances. So you end up with static member variables.


http://javasign.blogspot.com/
Ken Truitt
Ranch Hand

Joined: Aug 23, 2007
Posts: 124


compile error--illegal start of expression 'static int...'


SCJP 88% | SCWCD 84%
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 36514
    
  16
There is no such thing as a static local variable in Java; as Ken Truitt has shown, you mustn't even use the static keyword inside a method.
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19544
    
  16

In C this was necessary to not completely polute the global namespace. In Java, classes already split up the namespace, so a static field will work just fine.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 36514
    
  16
And the static keyword in Java means something different from the static keyword in C.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: difference between static local variables and static global variables.
 
Similar Threads
how the program works?
Difference in local & automatic
what is difference between
Static and Global variables
Variables