Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > final

Reply
Thread Tools

final

 
 
Ayrton
Guest
Posts: n/a
 
      07-01-2005
What is the important of this code:
.....
fianl JButton ....

Why final ?

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

 
Reply With Quote
 
 
 
 
Stefan Schulz
Guest
Posts: n/a
 
      07-01-2005
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"


 
Reply With Quote
 
 
 
 
Joan
Guest
Posts: n/a
 
      07-01-2005

"Stefan Schulz" <> wrote in message news.. .
> 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"
>
>


 
Reply With Quote
 
IchBin
Guest
Posts: n/a
 
      07-02-2005
Joan wrote:
>
> "Stefan Schulz" < <private.php?do=newpm&u=>> wrote
> in message news.. .
> > 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-)
 
Reply With Quote
 
Tor Iver Wilhelmsen
Guest
Posts: n/a
 
      07-02-2005
"Ayrton" <> writes:

> Why final ?


Why not?
 
Reply With Quote
 
Kevin McMurtrie
Guest
Posts: n/a
 
      07-02-2005
In article <>,
"Ayrton" <> 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.
 
Reply With Quote
 
ChrisWSU
Guest
Posts: n/a
 
      07-02-2005
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.

 
Reply With Quote
 
John C. Bollinger
Guest
Posts: n/a
 
      07-02-2005
Kevin McMurtrie wrote:
> In article <>,
> "Ayrton" <> 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

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Word open as Final, not Final Showing Markup Karl Engel Computer Support 4 12-19-2006 04:20 AM
Non-final class at compile-time, final at runtime pietdejong@gmail.com Java 5 11-17-2006 12:30 PM
Difference between static final members and final static members(if any)? JFCM Java 4 02-07-2006 11:32 AM
Extensions and Final Version of Firefox totsob Firefox 1 11-12-2004 01:27 PM
Final release Firefox 1.0 John Firefox 6 11-09-2004 08:46 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57