File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes Static variables? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Static variables?" Watch "Static variables?" New topic

Static variables?

Ganesan Ramakrishnan
Ranch Hand

Joined: Mar 18, 2008
Posts: 90
What is the use of static variables?
Ra Sank

Joined: Jun 02, 2008
Posts: 14
Static Variables are common to all the instances of a particular class where they declared and defined.

Learning Java.
Darryl Burke

Joined: May 03, 2008
Posts: 5115

To put it more correctly, static variables are class members, not instance members.

edit: and exist independently of any instance of the class being constructed or not.
[ June 16, 2008: Message edited by: Darryl Burke ]

luck, db
There are no new questions, but there may be new answers.
camilo lopes
Ranch Hand

Joined: Aug 08, 2007
Posts: 202
variable static you shared the value for all class and for one object scpecific. for example:
you are value dollar:

then this value �s shared for all class, not necessary create one instance for get the value this variable.

Brazil - Sun Certified Java Programmer - SCJP 5 About Java - Update every Week.
Guide SCJP - tips that you need know
Peter Chase
Ranch Hand

Joined: Oct 30, 2001
Posts: 1970
Originally posted by camilo lopes:

Off-topic, but important: -

Never use "double" or "float" for money calculations. Use integer arithmetic (in cents, pence etc.) or BigDecimal. If you don't know why, read up on floating-point arithmetic and why it is unsuitable for currency calculations.

Betty Rubble? Well, I would go with Betty... but I'd be thinking of Wilma.
Ganesan Ramakrishnan
Ranch Hand

Joined: Mar 18, 2008
Posts: 90
Thanks for all ('=').
I agree. Here's the link:
subject: Static variables?
It's not a secret anymore!