Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use constants in Java Foundation

2025-03-31 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

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!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 217

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report