• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

difference between static local variables and static global variables.

 
bharadwaz reddy
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hello,

please somebody explain me,the difference between static local variable and static global variable. with example programs.
 
Sachin Adat
Ranch Hand
Posts: 213
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How did you come arrive at this question.............
I've never heard anything about static local variable
 
Aurelian Tutuianu
Ranch Hand
Posts: 86
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Ken Truitt
Ranch Hand
Posts: 124
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


compile error--illegal start of expression 'static int...'
 
Campbell Ritchie
Sheriff
Pie
Posts: 49812
69
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 20610
63
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Campbell Ritchie
Sheriff
Pie
Posts: 49812
69
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And the static keyword in Java means something different from the static keyword in C.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic