• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Final Arguments ..

 
karimkhan pathan
Ranch Hand
Posts: 86
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can final arguments of a method can changed ??
 
Dawn Charangat
Ranch Hand
Posts: 249
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
final arguments in any scope cannot be changed. They can be read from, any number of times.
 
karimkhan pathan
Ranch Hand
Posts: 86
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks Dawn
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Their content can be changed though.
 
Campbell Ritchie
Sheriff
Pie
Posts: 49367
62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please explain more about changing content, Christophe.
 
Muhammad Khojaye
Ranch Hand
Posts: 449
IntelliJ IDE Java Scala
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
karimkhan pathan wrote:Can final arguments of a method can changed ??


Values cannot be modified after initialization. however, they are stored as values. Just to confuse things static final variables in Java are compiled as in-line constants. In other words, if you change a static final value, you need to recompile everything that uses it or they will continue using the old value. That catches out every Java newbie sooner or later.
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please explain more about changing content, Christophe.

 
karimkhan pathan
Ranch Hand
Posts: 86
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
But when a primitive is used as a argument for the method .
we cannot change the value !!
when we use a object ref how we can change the contents of the object?
 
Amy Crowley
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Final variables cannot be reassigned new values once they've been initialized. For object reference variables, this means that the final variable cannot be re-assigned to a different object. The object itself may be changed, however -- the certification tutorial i've been reading (SCJP 6 Study Guide, Sierra & Bates) put it this way:
There are no final objects, only final references.


 
Campbell Ritchie
Sheriff
Pie
Posts: 49367
62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
karimkhan pathan wrote:when we use a object ref how we can change the contents of the object?
That is what I expected, and why I sugested Christophe give us more details (thank you).

You cannot change which object it is, but the methods allow you to change the "state" of the object; its fields can be altered.
 
karimkhan pathan
Ranch Hand
Posts: 86
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks campbell...It was really helpful ...
 
Campbell Ritchie
Sheriff
Pie
Posts: 49367
62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You're welcome (on behalf of everybody who replied)
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic