Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   Java (http://www.velocityreviews.com/forums/f30-java.html)
-   -   final (http://www.velocityreviews.com/forums/t144582-final.html)

Ayrton 07-01-2005 05:37 PM

final
 
What is the important of this code:
.....
fianl JButton ....

Why final ?

--
Questa una firma automatica di MesNews.
Sito: http://www.mesnews.net


Stefan Schulz 07-01-2005 08:05 PM

Re: final
 
On Fri, 01 Jul 2005 17:37:53 +0000, Ayrton wrote:

> What is the important of this code:
> ....
> fianl JButton ....
>
> Why final ?


Because it pleases the dread gods of Javanor...

Impossible to answer without more code.

--
You can't run away forever,
But there's nothing wrong with getting a good head start.
--- Jim Steinman, "Rock and Roll Dreams Come Through"



Joan 07-01-2005 08:42 PM

Re: final
 

"Stefan Schulz" <terra@spacetime.de> wrote in message news:pan.2005.07.01.20.05.57.534015@spacetime.de.. .
> On Fri, 01 Jul 2005 17:37:53 +0000, Ayrton wrote:
>
> > What is the important of this code:
> > ....
> > fianl JButton ....
> >
> > Why final ?

Ontologies can validate

taxonomy membership


>
> Because it pleases the dread gods of Javanor...
>
> Impossible to answer without more code.
>
> --
> You can't run away forever,
> But there's nothing wrong with getting a good head start.
> --- Jim Steinman, "Rock and Roll Dreams Come Through"
>
>



IchBin 07-02-2005 01:07 AM

Re: final
 
Joan wrote:
>
> "Stefan Schulz" <terra@spacetime.de <mailto:terra@spacetime.de>> wrote
> in message news:pan.2005.07.01.20.05.57.534015@spacetime.de.. .
> > On Fri, 01 Jul 2005 17:37:53 +0000, Ayrton wrote:
> >
> > > What is the important of this code:
> > > ....
> > > fianl JButton ....
> > >
> > > Why final ?

>
> Ontologies can validate
>
> taxonomy membership
>
>
> >
> > Because it pleases the dread gods of Javanor...
> >
> > Impossible to answer without more code.
> >
> > --
> > You can't run away forever,
> > But there's nothing wrong with getting a good head start.
> > --- Jim Steinman, "Rock and Roll Dreams Come Through"
> >
> >

>

As others, you can not tell specifics without more code.

You can look at The Java Language Specification, Third Edition
http://java.sun.com/docs/books/jls/t...tml/j3TOC.html

or The Really Big Index, A list of all content pages in the The JavaTM
Tutorial
http://java.sun.com/docs/books/tutor...ybigindex.html

and look up the final modifier.

--


Thanks in Advance...
IchBin, Pocono Lake, Pa, USA
__________________________________________________ ________________________

' If there is one, Knowledge is the "Fountain of Youth"'
-William E. Taylor, Regular Guy (1952-)

Tor Iver Wilhelmsen 07-02-2005 07:13 AM

Re: final
 
"Ayrton" <alfonsopaglia@libero.it> writes:

> Why final ?


Why not?

Kevin McMurtrie 07-02-2005 09:12 AM

Re: final
 
In article <mn.0b967d572e476b7a.33486@libero.it>,
"Ayrton" <alfonsopaglia@libero.it> wrote:

> What is the important of this code:
> ....
> fianl JButton ....
>
> Why final ?


The compiler can do some optimizations on final variables, parameters,
and fields. Final variables make sure that you don't accidentally
re-assign the value. Final fields make sure that new constructors don't
forget to provide values. Final fields can make an object immutable so
it can be safely cached or placed in hash tables.

ChrisWSU 07-02-2005 09:38 PM

Re: final
 
as i understand it...

say final JButton button = ...
the value stored in button (reference to the JButton object) is
constant and cannot be changed. because of this the compiler can use
certain optimizations. Also since the value is fixed the compiler can
do certain things with it, that it cannot do with normal references.
For example.

public class A {
public final String s = "a";
...
...
public void test(){
Thread t = new Thread( new Runnable(){
public void run(){ System.out.println(s);}
});
t.start();
}
}

the annoynmous inner class can use the reference. I just wrote that
out of hat so sry if i missed something. With objects although the
instance is final, you can still make motifications to that instance,
but with primitives like ints the value cannot be changed.


John C. Bollinger 07-02-2005 10:29 PM

Re: final
 
Kevin McMurtrie wrote:
> In article <mn.0b967d572e476b7a.33486@libero.it>,
> "Ayrton" <alfonsopaglia@libero.it> wrote:
>
>
>>What is the important of this code:
>>....
>>fianl JButton ....
>>
>>Why final ?

>
>
> The compiler can do some optimizations on final variables, parameters,
> and fields. Final variables make sure that you don't accidentally
> re-assign the value. Final fields make sure that new constructors don't
> forget to provide values. Final fields can make an object immutable so
> it can be safely cached or placed in hash tables.


And, considering that we are talking about Swing, it may be relevant
that final local variables and method parameters can be accessed by
local inner classes (named or anonymous).

--
John Bollinger
jobollin@indiana.edu


All times are GMT. The time now is 04:07 AM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.