Top Answer
User Avatar
Wiki User
Answered 2013-09-09 21:09:52

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.

User Avatar

Your Answer

Related Questions

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.

there is no difference between java2 and java. its same.

A constant is a term used in java whose values doesn't change during the execution of the program, while, a variable's value can be changed during the execution.

difference between inheritaens & pholimorephezem in java

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...

Nothing, java is another name for coffee.

Variables can be changed. Constants (declared with the reserved word final) cannot be. They are typically all capitalized.example: final int FREEZING_POINT=32;

There is no such thing as an access specifier in Java.

Unix is an operating system, Java is a language.

Final refers to happening at the end of something; finally means at long last while finalize means to put the last touches to something.

There is no such thing as an access specifier in Java.

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;

A person can tell the difference between a male and female java finch by the birds beaks. The beaks will be shaped differently.

java is a programming language/platform that embodies object oriented programming concepts. The question of what is the difference is like asking what is the difference between cars and a volvo.

Java doesn't have pointers. C++ has pointers.

Java allows you to define constants through keyword "final". It can be implemented on your classes, methods and datatypes. Interestingly, Java have reserved const keyword in it's library but there is no function associated or defined with it. -Ravi

javax.swing is a GUI package in Java. The Frame class is an element of the java.awt GUI package.

major diiffernce cpp is compiler based and java is interperter based and java is platform independant.

Programming languages share a lot of the same characteristics. One main difference between Java and Python is the function identifier. In Java it is function and in Python it is def.

The use of final denotes that a variable is a constant. For example: final int PI = 3.14; makes PI a constant. This is useful because now PI can't be changed, even accidentally, by you, the program, another programmer, or a user. Once a value is final, it is permanent, and can be used as a constant. Note: usually programmers capitalize the names of constants, just to make it clear that the value is a constant.