The final keyword in Java has more in common with a C++ reference than it does with a C++ const. That is, a reference may only be assigned once, but the referenced object may still be modified. A C++ reference is the same as a constant pointer (rather than a pointer to const), insofar as the pointer cannot be modified, but the memory being pointed to can. This emulates some of the behaviour of the Java final keyword. But while a C++ const can easily be cast to a volatile, you simply cannot do that in Java. Moreover, a Java final class cannot be sub-classed, you simply cannot do that in C++. Comparing Java final to C++ const is somewhat pointless since they have absolutely nothing whatsoever in common; the list of differences could fill a book.
difference between constant and static variables in java
A constant in Java is defined using the "final" modifier. For instance: final double Density_Of_Water = 1.000; would set Density_Of_Water to 1.000. This value can not be modified throughout the program because "final" told the compiler that this value would not change. A variable however, can be changed by the user throughout the program.
-Public to all - Static to access with Class Name - Final to change( constant and not alowed to change) Just use it along with class name. (As implied above, a 'public static final' variable in Java is what other languages would call a Constant. )
Unix is an operating system, Java is a language.
Rowset
difference between constant and static variables in java
A constant in Java is defined using the "final" modifier. For instance: final double Density_Of_Water = 1.000; would set Density_Of_Water to 1.000. This value can not be modified throughout the program because "final" told the compiler that this value would not change. A variable however, can be changed by the user throughout the program.
constant is does not change the value of during the excution of programvariable it changes the value during the excution of program
They are different versions. Java 5 is newer than Java 2. Think of it like the difference between the Playstation 1 and the Playstation 3.
-Public to all - Static to access with Class Name - Final to change( constant and not alowed to change) Just use it along with class name. (As implied above, a 'public static final' variable in Java is what other languages would call a Constant. )
Java is object oriented, C is not...
kamina
kamina
Unix is an operating system, Java is a language.
Rowset
JAD-Java Application Description JAR-Java archive
yes use the final keyword, normally variables declared final use all capital letters but this is not required final int A = 10;