This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
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 Murach's Java Servlets and JSP this week in the Servlets 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: 19651
    
  18

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: 19651
    
  18

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