File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes Final Arguments Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Final Arguments" Watch "Final Arguments" New topic
Author

Final Arguments

Saral Saxena
Ranch Hand

Joined: Apr 22, 2011
Posts: 202

Hi folks,

WHILE GOING THROUGH FINAL ARGUEMENTS...
public Record getRecord(int fileNumber, final int recordNumber) {}

...
the variable recNumber is declared as final, which of course means it can't be modified within the method..explain it in detail...!!
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 19070
    
  40

Saral Saxena wrote:Hi folks,

WHILE GOING THROUGH FINAL ARGUEMENTS...
public Record getRecord(int fileNumber, final int recordNumber) {}

...
the variable recNumber is declared as final, which of course means it can't be modified within the method..explain it in detail...!!


What is there to explain? Final means exactly what you said it means.

Henry


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 40052
    
  28
Read this. Please go back and edit your post in line with that link.

It means it can’t be reassigned within the method. If they have gone to the trouble of marking the second parameter (not argument) final, why haven’t they marked them both final? I cannot explain any more with the information I have been given.
If you think it means you can’t alter the original value of the argument (not parameter), you have not understood pass-by-value.
Jeff Verdegan
Bartender

Joined: Jan 03, 2004
Posts: 6109
    
    6

Saral Saxena wrote:
explain it in detail...!!


Since English is not your native language, you may not be aware of it, but that sounds bossy and rude. Simply adding the word "please", or phrasing it as a question, such as, "Could someone explain it?" would make it more polite.

Also, you need to be clear about what you don't understand. Don't make the mistake of thinking these forums are a substitute for you spending time--a LOT of time--researching, studying, reading, thinking, getting frustrated but continuing to work on it, writing code, etc.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Final Arguments