answersLogoWhite

0


Best Answer

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.

User Avatar

Wiki User

14y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: What is the difference between a constant and a variable in java programming language?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

What is the difference between constant speed and variable speed?

The difference is that constant speed doesn't change but variable speed does. (change)


WAP to show the difference between a variable and static variable?

difference between constant and static variables in java


What is the difference between a variable and a literal in prgramming?

a literal is a constant value, the difference is a variable can change it's value.


What the difference between a variable and control?

The difference between a controlled variable and a variable is in their state. A controlled variable is something which is rigid and constant while a variable is liable to change and inconsistent.


What is a computer variables?

In a programming language, a variable is a name for a place where information is stored.


What is difference between variable and constant?

Whether or not you can change its value.


What is a constant variables in c language?

It are a variable you add modifer 'const' to. It means these variable mustn't be modified.


What are the differences of a constant and a variable?

A constant has only the exact value it's declared and can never be changed. A variable can have any number of values assigned. In programming, a variable can be given a value later in the code but can only be changed during runtime if its been declared as a pointer.


What is a constant as used in C programming?

A variable of which the value cannot change. Example of its usage: const int foo = 5;


Difference between variable and constant in statistics?

When referring to statistics, variable means that numbers change and can go up and down. If something is constant, numbers remain unchanged.


How do you delete reference of an object?

This often happens automatically, when the variable that references an object goes out of scope. Alternatively, you can set the variable that refers to an object to some reserved value, such as NULL (details vary, depending on the programming language).This often happens automatically, when the variable that references an object goes out of scope. Alternatively, you can set the variable that refers to an object to some reserved value, such as NULL (details vary, depending on the programming language).This often happens automatically, when the variable that references an object goes out of scope. Alternatively, you can set the variable that refers to an object to some reserved value, such as NULL (details vary, depending on the programming language).This often happens automatically, when the variable that references an object goes out of scope. Alternatively, you can set the variable that refers to an object to some reserved value, such as NULL (details vary, depending on the programming language).


Why use static variable in programming language?

For C programming, the use of a static variable has two uses: One reason is to hide the variable from other modules. The scope of the static variable is limited to the compilation unit that it is described in. The second use of a static variable is to keep the value of the variable intact through the entire program execution unit.