• Post Reply Bookmark Topic Watch Topic
  • New Topic

static keyword  RSS feed

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
what is the use of declaring a object static, can anyone explain the behaviour of that reference ?
e.g.
class Sample
{
//..
//...
}
class SampleMain
{
public static void main(String arg[])
{
static Sample sample = new Sample();
///.....
//....
}
}
 
Ranch Hand
Posts: 2545
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A static variable means the variable is gloabal, it retains its value even the instance who initiates it is destroyed.
HTH.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!