Final variable in java ?

Dear all,What is Final variable in java ?Taton
[67 byte] By [Tatona] at [2007-10-3 4:11:32]
# 1
Nothing, since there is no Final keyword/identifier or Final object, unless you've made one yourself, or have some third party API with it. In which case, you tell us.
masijade.a at 2007-7-14 22:12:06 > top of Java-index,Java Essentials,New To Java...
# 2
I will take a wild guess here: maybe the OP meant final? http://java.sun.com/docs/books/jls/second_edition/html/typesValues.doc.html#10931
jfbrierea at 2007-7-14 22:12:06 > top of Java-index,Java Essentials,New To Java...
# 3

Is a nonaccess class and member modifier.

A final class cannot be subclassed.

Final methods cannot be overridden in a subclass.

Instance final variables are not initialized by default.

Declaring a variable with the final keyword makes it impossible to reinitialize that variable once it has been initialized with an explicit value

-For primitives, this means that once the variable is assigned a value, the value can't be altered. For example, if you assign 10 to the int variable x, then x is going to stay 10, forever.

-For object reference variables, this means that a reference variable marked final can't ever be reassigned to refer to a different object.

final is the only modifier available to local variables and method arguments. Means it can't be modified within the method.

final Summary:

Class = Cannot be extended

Method = Cannot be overridden

Variable = Cannot be reinitialized

JLuisa at 2007-7-14 22:12:06 > top of Java-index,Java Essentials,New To Java...
# 4
@OP. I thought you said that you had posted your last homework question.Kaj
kajbja at 2007-7-14 22:12:06 > top of Java-index,Java Essentials,New To Java...
# 5

> I will take a wild guess here: maybe the OP meant

> final?

> http://java.sun.com/docs/books/jls/second_edition/html

> /typesValues.doc.html#10931

Of course he did. I was just pricking him. You need to take a look at his posting history. Lots of homework, with only lame attempts at any creative twists to the questions. ;)

masijade.a at 2007-7-14 22:12:06 > top of Java-index,Java Essentials,New To Java...
# 6

> Dear all,

> What is Final variable in java ?

> Taton

What have you done to try to find the answer yourself? Did you google? No. Did you bother to look at the index of your textbook? No. Did you do anything other than post your homework and wait for others to do your work for you? No.

jverda at 2007-7-14 22:12:06 > top of Java-index,Java Essentials,New To Java...
# 7

> > Dear all,

> > What is Final variable in java ?

> > Taton

>

> What have you done to try to find the answer

> yourself? Did you google? No. Did you bother to look

> at the index of your textbook? No. Did you do

> anything other than post your homework and wait for

> others to do your work for you? No.

I did all things

public class Finaljava {

final static int hi = 9;

public static void main(String args[]) {

Finaljava fi = new Finaljava();

//fi.hi;

//Finaljava.hi;

System.out.print(hi);

}

}

Tatona at 2007-7-14 22:12:06 > top of Java-index,Java Essentials,New To Java...
# 8
> I did all things I find that very hard to believe. Find and post the section from your textbook that explains final. If you manage that and still have no idea what it means then you really are clueless and should consider dropping the course.
floundera at 2007-7-14 22:12:06 > top of Java-index,Java Essentials,New To Java...
# 9

> > > Dear all,

> > > What is Final variable in java ?

> > > Taton

> >

> > What have you done to try to find the answer

> > yourself? Did you google? No. Did you bother to

> look

> > at the index of your textbook? No. Did you do

> > anything other than post your homework and wait

> for

> > others to do your work for you? No.

> I did all things

I see.

Then perhaps you might share what you found and what parts of it you didn't understand. Otherwise, anybody who might try to help you would just be repeating what you already read and did not understand. You need to provide:

a) Evidence of what you've tried so far, so that people here won't think you're just trying to get others to do your work

and

b) Details about what in (a) you are confused about, so that people can direct their answers toward the appropriate aspects of the broader question. (Note that (a) also helps with this.)

jverda at 2007-7-14 22:12:06 > top of Java-index,Java Essentials,New To Java...