jQuery in Action, 2nd edition*
The moose likes Beginning Java and the fly likes Final Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Final" Watch "Final" New topic
Author

Final

shruti patel
Ranch Hand

Joined: Mar 10, 2008
Posts: 52
what is difference between const and final?
Sagar Rohankar
Ranch Hand

Joined: Feb 19, 2008
Posts: 2902
    
    1

there is no keyword in Java named 'const' !


[LEARNING bLOG] | [Freelance Web Designer] | [and "Rohan" is part of my surname]
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19556
    
  16

const is a reserved word that you can't use yet. If you put "const" in your code it will be a compiler error, no matter if you use it as a modifier such as final or as a variable name.


I'd like Sun to include const in the future though, even if it is only for arrays. Now you can specify an array reference to be final, but the contents can still be changed. The const reserved word could be used for this. It isn't at the moment though.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Sagar Rohankar
Ranch Hand

Joined: Feb 19, 2008
Posts: 2902
    
    1

Oops , I dont know about that !
Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575

Originally posted by Sagar Rohankar:
Oops , I dont know about that !


anyway now you know right Sagar Rohankar?
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19556
    
  16

And knowing is half the battle!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Final
 
Similar Threads
avoid running final clouse
final variable question from kb
alternative for interface
Your favorite animated movies
Football 2010 Winner speculation