• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

Static variable,...

 
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I need to know abt static


Thanks in advance
 
Ranch Hand
Posts: 809
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What exactly you are trying to ask.

static is class thing.


Naseem
 
Banu Ravi
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sorry I want to know what happens when a variable/class/method declared static.

If i'm still not clear.

I'm very sorry.

Thanks.

[ June 17, 2006: Message edited by: Banu Ravi ]
[ June 17, 2006: Message edited by: Banu Ravi ]
 
Ranch Hand
Posts: 263
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi,
static is a reserved keyword in java. a keyword static lets a method run without any instance of the class. Static means behaviour is independent of any instance variable. Math class is example of static.

points to remember regarding static

1) static methods can'ts use non-static methods, either.
2) value is the same for all instances of the class.
3) static final variables are constants.
4) static variables get default values just like instance variables.
5) static variables are shared.
6) all instances of the same class share a single copy of the static variables.
7) all the static variables is initialized only one time when class is loaded not every time when new instance is made.



Regards,
Nitin
 
Banu Ravi
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks nitin
it was very clear
static variables & method ok.

can u pls tell me abt a static class.
[ June 18, 2006: Message edited by: Banu Ravi ]
 
nitin pokhriyal
Ranch Hand
Posts: 263
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
static classes are usually a namespace resolution than about an implicit relationship between the outer class and inner class. Actually static class
is just like a static member of a class. and behave just like a static method.
If static keyword is used in amethod or a variable then it means that it is not instance specific. As it is, static nested class does not have access to the instance of the outer class. As the regular inner class enjoys the special
relationship with a outer class ,a static nested class does not. It is simply a noninner class scoped within another.
 
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

There are examples in JLS, please go through that.
And some could also confuse you..... :-)
 
Banu Ravi
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks
 
The fastest and most reliable components of any system are those that are not there. Tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic