How to use constants in Java Foundation
This article mainly shows you "how to use constants in the basis of Java". The content is simple and clear. I hope it can help you solve your doubts. Let me lead you to study and learn this article "how to use constants in Java Foundation".
/ * the constants in java are divided into the following categories 1. Integer constant 2. Floating point constant 3. Character constant 4. Boolean constant 5. String constant * / public class FinalVariable {public static void main (String [] args) {/ / constant definition: immutable variable / / 1. Integer constant final int UP=0; final int DOWN=1; final int LEFT=2; final int RIGHT=3; System.out.println (UP); System.out.println (DOWN); System.out.println (LEFT); System.out.println (RIGHT) / * Note: 1. Constants are generally defined in uppercase * / 2. Floating point constant final float PI=3.14f; System.out.println (PI); / / 3. Boolean constant final boolean RUN=true; System.out.println (RUN); / / 4. Final char constant character constants: System.out.println (A); System.out.println ('\ r'); System.out.println ('\'); System.out.println ('\ "); System.out.println ('\'); / / 5. String constant final String CONST= "everlasting love"; System.out.println (CONST);}} / * Summary: 1. The naming rules of constants are the same as variables. Constants are generally capitalized 3. The constant is preceded by the final keyword 4. Constants cannot be changed * / the above is all the content of the article "how to use constants in Java Foundation". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!