🔥Limited Offer: Get 50% OFFon AI & Full Stack Courses🔥
Back to Java Notes
Topic #13

Constants (Final)


Constants (final keyword)

When you do not want a variable's value to change, use the final keyword.

A variable declared with final becomes a constant, which means unchangeable and read-only:

Example

final int myNum = 15;
myNum = 20;  // Error: cannot assign a value to final variable 'myNum'

When to Use final?

You should declare variables as final when their values should never change. For example, the number of minutes in an hour, or your birth year:

Example

final int MINUTES_PER_HOUR = 60;
final int BIRTHYEAR = 1980;

Note: By convention, final variables in Java are usually written in upper case (e.g. BIRTHYEAR). It is not required, but useful for code readability and common for many programmers.

Want to go beyond the notes?

Join CodingNow 2.0's Java course — live mentorship, real projects, and 100% placement support.

Enroll Now — Free Demo Available

Constants (Final) – FAQs

Quick answers about learning Constants (Final) in Java.

This free note from CodingNow 2.0 explains Constants (Final) in Java — concept, syntax and worked code examples you can copy, run and revise before interviews.
Yes. Every Java topic on CodingNow 2.0, including Constants (Final), is 100% free with no signup required.
With focused practice, most students grasp Constants (Final) in 1–3 days from these notes; pairing it with CodingNow 2.0's mentor-led course takes you to job-ready depth faster.
Use the code examples in this note, then ask doubts for free on the CodingNow 2.0 Community (/community) — expert instructors answer within 24 hours.
WhatsApp
Call NowEnroll Now