Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Static reference varaible.

 
Narasimha Rao B.
Ranch Hand
Posts: 205
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
If we declare a varaible as static, it means it is a class variable as every one knows.
If we declare a reference variable as static, what it means?.....
Thanks in Advance,
Narasimha.
 
Valentin Crettaz
Gold Digger
Sheriff
Posts: 7610
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Could you explain how a variable is different from a reference variable?
Actually, there are two kinds of variables, reference variables that reference objects on the heap, and primitive variable that hold primitive values (1, 4.56f, false, ...).
When using the term "variable", we mean both reference and primitive variables. Both of them may be declared static, that is, they pertain to the class and not to an instance of that class.
An example of a static primitive variable could be a instance counter that increments each time an instance of the class is created.

An example of a static reference variable could be a singleton instance of a class.

[ March 26, 2003: Message edited by: Valentin Crettaz ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic