Question : what is difference between constant and final in java
Answered by : ahmad-mujtaba
Constant is the concept, the property of the variable.
final is the java keyword to declare a constant variable.
Source : https://stackoverflow.com/questions/30545594/what-is-the-difference-between-constant-variables-and-final-variables-in-java | Last Update : Sun, 27 Feb 22
Question : difference between final and constant in java
Answered by : real-rattlesnake-lqunx7ubt1rx
class Data {
final int integerConstant = 20;
}
public class ConstantExample {
public static void main(String args[]) {
Data obj1 = new Data();
System.out.println("value of integerConstant: "+obj1.integerConstant);
Data obj2 = new Data();
System.out.println("value of integerConstant: "+obj2.integerConstant);
}
}
Source : https://www.tutorialspoint.com/difference-between-constants-and-final-variables-in-java | Last Update : Sat, 13 Nov 21