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

What should be paid attention to when using variables in java

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)05/31 Report--

This article introduces the relevant knowledge of "what to pay attention to when using variables in java". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

Description

1. Every variable has a type, which can be either a basic type or a reference type.

2. The variable name must be a legal identifier.

3. Variable declaration is a complete statement, so each declaration must end with a semicolon.

Example

Public class demo04 {/ / class variable static double salary = 2500; / / attribute variable / / instance variable: subordinate to the object; if not initialized, the default value for this type is 0.0. / / Boolean value: the default value is false / / except for the basic type, all default values are null; String name; int age; / / main method public static void main (String [] args) {/ / local variables: values must be declared and initialized Int I = 10; System.out.println (I); / / use instance variable / / variable type variable name = new Demo04 (); demo04 demo04 = new demo04 (); / / alt+enter System.out.println (demo04.age); System.out.println (demo04.name); System.out.println (salary) } / / other methods public void add () {System.out.println (1);}} "what to pay attention to when using variables in java" is introduced here. Thank you for your reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

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: 0

*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

Internet Technology

Wechat

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

12
Report