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 final variables Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

JavaRanch » Java Forums » Java » Beginning Java
Bookmark "final variables" Watch "final variables" New topic

final variables

Anthony Smith
Ranch Hand

Joined: Sep 10, 2001
Posts: 285
Ok, for a final variable...
If I declare it as a class member and dont assign it a variable then I can only declare it in a constructor?
Ok, if I declare it static do i have to give it a value then cause I cant seem to assign it a value anywhere else.
Anthony Villanueva
Ranch Hand

Joined: Mar 22, 2002
Posts: 1055
Hi Anthony, you can use a static initializer. See sample code below:
subject: final variables