How to define a constant variable in Java?
Answer / vidya bhushan dwivedi
The variable should be declared as static and final. So only one copy of the variable exists for all instances of the class and the value can't be changed also.
static final int MAX_LENGTH = 50; is an example for constant.
| Is This Answer Correct ? | 6 Yes | 0 No |
Can we use a switch statement with strings?
What is files manifesting?
How to sort an array from smallest to largest java?
When is the finalize() called? What is the purpose of finalization?
Is 'null' a keyword?
What is classes in java?
Can final class have constructor?
what are the differences between final,finally,finalize methods?
What is difference between pointer and reference?
Which list is sorted in java?
Explain inheritance in java?
What is difference between arraylist and list in java?