• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Final Arguments

 
Saral Saxena
Ranch Hand
Posts: 203
Eclipse IDE Java Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Marshal
Pie
Posts: 22124
88
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Campbell Ritchie
Sheriff
Posts: 51456
87
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 6109
6
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic