Java: Constants

Some data, such as mathematical constants, never changes. Take the number π. Approximately it is always equal to 3.14 and cannot change.

To access such data in Java, it is customary to use constants.

final var PI = 3.14;
System.out.print(PI); // 3.14

Constants are usually called uppercase letters with _ as a separator. A constant, like a variable, can be used in any expression. The only restriction is that the constant cannot be changed, which sounds quite logical.


Create the constant DRAGONS_BORN_COUNT and write the number 3 in it - the number of dragons born to Dayenerys.

If you got stuck and don't know what to do, you can ask a question in our huge and friendly community