aspose file tools*
The moose likes Beginning Java and the fly likes Difference  between const & final  in java ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Difference  between const & final  in java ?" Watch "Difference  between const & final  in java ?" New topic
Author

Difference between const & final in java ?

Thennam Pandian
Ranch Hand

Joined: Oct 11, 2005
Posts: 163
dear friends,


Both const & final are used to represent Constant value .

what is difference between const & final in java.
Keith Lynn
Ranch Hand

Joined: Feb 07, 2005
Posts: 2367
const is not used to represent anything. It is reserved, but isn't used.
Nigel Browne
Ranch Hand

Joined: May 15, 2001
Posts: 673
const is a reserved keyword that is not currently used. Its inclusion as a keyword was to assist compilers in catching out programs where this C++ keyword had been used in error.
Ilja Preuss
author
Sheriff

Joined: Jul 11, 2001
Posts: 14112
final on a reference variable just means that the reference cannot be changed to reference a different object.

As far as I know, const in C++ means that you actually cannot change the object itself (for example by calling mutator methods).


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
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Difference between const & final in java ?