Is there a reason to use 揻inal?for parameter declarations?

Is there a reason to use 揻inal?for parameter declarations?Using final in a parameter declaration, does it make a difference? Especially with comparing a parameter declaration without the final keyword?
[215 byte] By [vopoa] at [2007-11-27 10:01:09]
# 1
If you use final, you won't accidentally change something that shouldn't be changed. And it means when you or somebody else read the code later, you will know that those values are not intended to be modified.
jverda at 2007-7-13 0:33:12 > top of Java-index,Java Essentials,New To Java...
# 2
but what about referencing the method, does it affect the reference? Or does the code can only reference a certain type?
vopoa at 2007-7-13 0:33:12 > top of Java-index,Java Essentials,New To Java...
# 3
> but what about referencing the method, does it affect> the reference? Huh?> Or does the code can only reference a certain type?Huh?
jverda at 2007-7-13 0:33:12 > top of Java-index,Java Essentials,New To Java...
# 4
> but what about referencing the method, does it affect> the reference? > Or does the code can only reference a certain type?[Ron Burgandy]That doesn't make any sense.[/Ron Burgandy]
Navy_Codera at 2007-7-13 0:33:12 > top of Java-index,Java Essentials,New To Java...
# 5

> > but what about referencing the method, does it

> affect

> > the reference?

>

> Huh?

>

I'm just wondering if a method has a final parameter like:

public void vo(final String h){..}

when referencing that method, does the variable inside have to be a constant String:

vopoa at 2007-7-13 0:33:12 > top of Java-index,Java Essentials,New To Java...
# 6

By making your parameter final, the following will not compile.

public void foo(final String s) {

s = "hello"; // error

}

What do you mean by "does the variable inside have to be a constant String"?

floundera at 2007-7-13 0:33:12 > top of Java-index,Java Essentials,New To Java...
# 7

> By making your parameter final, the following will

> not compile.

> [code]

> public void foo(final String s) {

>s = "hello"; // error

> /code]

> What do you mean by "does the variable inside have to

> be a constant String"?

I was wondering if the method was referenced in another class, does the variable that goes into that method have to be a constant.

But I fgured it out, the variable doesn't have to be a constant

Message was edited by:

vopo

vopoa at 2007-7-13 0:33:12 > top of Java-index,Java Essentials,New To Java...
# 8

> > > but what about referencing the method, does it

> > affect

> > > the reference?

> >

> > Huh?

> >

> I'm just wondering if a method has a final parameter

> like:

> public void vo(final String h){..}

>

> when referencing that method, does the variable

> inside have to be a constant String:

No.

Final simply means that that parameter's value can't change. It has nothing to do with the caller's variable.

void foo(final Bar bar) {}

...

Bar bar = someBar;

foo(bar); // caller's bar is not final, but that's ok

jverda at 2007-7-13 0:33:12 > top of Java-index,Java Essentials,New To Java...