| Author |
Final Arguments ..
|
karimkhan pathan
Ranch Hand
Joined: Jul 14, 2008
Posts: 86
|
|
|
Can final arguments of a method can changed ??
|
karim
|
 |
Dawn Charangat
Ranch Hand
Joined: Apr 26, 2007
Posts: 249
|
|
|
final arguments in any scope cannot be changed. They can be read from, any number of times.
|
 |
karimkhan pathan
Ranch Hand
Joined: Jul 14, 2008
Posts: 86
|
|
|
thanks Dawn
|
 |
Christophe Verré
Sheriff
Joined: Nov 24, 2005
Posts: 14685
|
|
|
Their content can be changed though.
|
[My Blog]
All roads lead to JavaRanch
|
 |
Campbell Ritchie
Sheriff
Joined: Oct 13, 2005
Posts: 32833
|
|
|
Please explain more about changing content, Christophe.
|
 |
Muhammad Khojaye
Ranch Hand
Joined: Apr 12, 2009
Posts: 341
|
|
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.
|
http://muhammadkhojaye.blogspot.com/
|
 |
Christophe Verré
Sheriff
Joined: Nov 24, 2005
Posts: 14685
|
|
Please explain more about changing content, Christophe.
|
 |
karimkhan pathan
Ranch Hand
Joined: Jul 14, 2008
Posts: 86
|
|
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
Joined: Apr 19, 2009
Posts: 6
|
|
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
Joined: Oct 13, 2005
Posts: 32833
|
|
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
Joined: Jul 14, 2008
Posts: 86
|
|
Thanks campbell...It was really helpful ...
|
 |
Campbell Ritchie
Sheriff
Joined: Oct 13, 2005
Posts: 32833
|
|
You're welcome (on behalf of everybody who replied)
|
 |
 |
|
|
subject: Final Arguments ..
|
|
|