wood burning stoves 2.0
The moose likes Beginning Java and the fly likes final keyword Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "final keyword" Watch "final keyword" New topic

final keyword

alec stewart stewart
Ranch Hand

Joined: Dec 23, 2003
Posts: 71
if i have declared a variable as
final int a;
in a public class
can i access that variable in other class
Vicken Karaoghlanian
Ranch Hand

Joined: Jul 21, 2003
Posts: 522
Hi alec, yes you can.

- Do not try and bend the spoon. That's impossible. Instead, only try to realize the truth. - What truth? - That there is no spoon!!!
Ilja Preuss

Joined: Jul 11, 2001
Posts: 14112
Trying it would have probably been less work than formulating the question... :roll:

The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
Wayne L Johnson
Ranch Hand

Joined: Sep 03, 2003
Posts: 399
You would control the visibility by using "private", "protected", "public" or default/package (no modifier, as in your example), just like any other instance variable. The "final" simply means it can't be changed.
I agree. Here's the link: http://aspose.com/file-tools
subject: final keyword
It's not a secret anymore!