Computer Science, asked by pritijaiswal96, 9 months ago

Syntactic representation of constant values in Java programs: *​

Answers

Answered by mdhyan720
1

Answer:

c# or html

Explanation:

Answered by Anonymous
12

Answer:

A constant is a variable whose value cannot change once it has been assigned. Java doesn't have built-in support for constants.

A constant can make our program more easily read and understood by others. In addition, a constant is cached by the JVM as well as our application, so using a constant can improve performance.

To define a variable as a constant, we just need to add the keyword “final” in front of the variable declaration.

Syntax

modifier final data Type variable Name = value; //global constant

modifier static final data Type variable Name = value; //constant within a class

Notes

It is convention to capitalize the variable name of a constant.

Declaring a field as 'final' ensures that it is constant and cannot change.

The modifier specifies the scope of the constant.

Constants are very popular with classes. Because the value of a constant doesn't change between created objects, it is usually declared static. The static keyword changes the way the value is accessed: the value of the constant isn't accessed using the object, but with the class name itself.

Similar questions