in JAVA by
Q:
What is a compile time constant in Java? What is the risk of using it?

1 Answer

0 votes
by
public static final variables are also known as a compile time constant, the public is optional there. They are replaced with actual values at compile time because compiler know their value up-front and also knows that it cannot be changed during run-time. One of the problem with this is that if you happened to use a public static final variable from some in-house or third party library and their value changed later than your client will still be using old value even after you deploy a new version of JARs. To avoid that, make sure you compile your program when you upgrade dependency JAR files.

Related questions

0 votes
asked Jun 16, 2019 in JAVA by reins.robin
+1 vote
asked Feb 8, 2020 in JAVA by rahuljain1
0 votes
asked Feb 8, 2020 in JAVA by rahuljain1
...