Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

static final variable

Status
Not open for further replies.

yytan

Programmer
May 8, 2002
113
MY
hi there;

as i understand, if we declared the variable static, this variable will share among the class without have a copy of its.

if we declared a final variable, it will prevent from changing.

what is definition if i declared a variable as
static final int/String ?

thanks in advance!
 
Static also means that you can access the the data without creating an object of the class. final static can be used to declare "constants" that you want other classes to be able to acces. One example is the java.lang.Math class. It has two variables declared as static final, PI and E. You can use these constants by just writing Math.PI or Math.E. If they wouldn't have been declared as static you would have to create a Math object first and then use myMathObj.PI
 
dear sailerboy;

thanks for ur information :)
 
one more thing, is there any different between <b>final static and static final?</b>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top