How to declare constant in java?

 

public static final int CONSTANT_CNT = 7;

Static :  Static causes final variable to be available irrespective of  instance of the class is loaded.

final : Final takes care that variable cannot be modified.

Note : Java constants normally declared in UPPER CASE and words are separated by underscore.
Share on Google Plus

About Pranav

This is a short description in the author block about the author. You edit it by entering text in the "Biographical Info" field in the user admin panel.
    Blogger Comment
    Facebook Comment

0 comments:

Post a Comment