Skip to content

Commit 2ac3fd0

Browse files
committed
Update README.md
1 parent bacf53e commit 2ac3fd0

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

README.md

+7-5
Original file line numberDiff line numberDiff line change
@@ -2446,21 +2446,23 @@ public class Example {
24462446
<b><a href="#related-interview-questions">↥ back to top</a></b>
24472447
</div>
24482448
2449-
## Q. What is a compile time constant in Java? What is the risk of using it?
2449+
## Q. What is a compile time constant in Java?
24502450
24512451
If a primitive type or a string is defined as a constant and the value is known at compile time, the compiler replaces the constant name everywhere in the code with its value. This is called a compile-time constant.
24522452
24532453
**Compile time constant must be:**
24542454
2455-
* declared final
2456-
* primitive or String
2457-
* initialized within declaration
2458-
* initialized with constant expression
2455+
* Declared final
2456+
* Primitive or String
2457+
* Initialized within declaration
2458+
* Initialized with constant expression
24592459
24602460
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.
2461+
24612462
```java
24622463
private final int x = 10;
24632464
```
2465+
24642466
<div align="right">
24652467
<b><a href="#related-interview-questions">↥ back to top</a></b>
24662468
</div>

0 commit comments

Comments
 (0)