Personal understanding of JAVA basic data types

Java personal understanding

JAVA language cross-platform does not distinguish between operating systems. The
reason is that the Java virtual machine JVM, local translation, JVM is the system's own, JVM itself is not cross-platform, JAVA is cross-platform, the credit is JVM

JRE and JDK
JRE JAVA program runtime environment, including JVM and the core class library required by runtime
JDK JAVA program development kit, including jre and tools used by developers,
so if you want to run, just install JRE, if If you want to develop a new java program, you must install JDK
Insert picture description here

Explanation of two built-in programs in JDK

Insert picture description here
Javac.exe compiler
Java.exe interpreter

Keyword understanding

Keyword features:
1. Completely lowercase letters.
2. In the enhanced version of Notepad, keywords will have special colors.
Common key machines can be Baidu. Many
class names, variable names, and method names are also considered as identifiers. I chose my own name. For beginners like me, I recommend using English capitalization and numbers

Identifier understanding

It means that the content defined by ourselves in the program, such as the name of the class, the name of the method, and the name of the variable, all belong to the identifier.
Naming rules:
Identifiers can include English letters, numbers, $ signs, and _underscores. They
can include numbers, but they cannot start with numbers. They
cannot be keywords with the system

Naming specification:
class name specification: the first letter of each word is capitalized, big tuofeng mode
Variable name specification: the first letter is lowercase, the first letter of each word after it is capitalized, small hump mode
Method name specification: the same as the variable name specification

Constant understanding

Constant, refers to the fixed data during the running of the JAVA program

Common constants:
1. The string constant "abc" "hello" "123" in the double quotation mark of the string constant
2. The number written directly on the integer constant without a decimal point
3. A floating-point number constant with a decimal point, 3.14
4. A character constant , A single character "A", "b", "9", "中" enclosed in English single quotation marks, JAVA is also a Chinese character, but the single quotation mark cannot be empty. If it is empty, an error will be reported.
5. Boolean constant There are only two values, true, false
6, empty constant null, which means there is no data

public class Gself {
    
      //类名 Gself
    /*main()方法是Java应用程bai序的入口方法,也就是du说,程序在运行zhi的时候,
    第一个执行dao的方法就是main()方法,这个方法和其他的方 法有很大的不同,比如方法的
    名字必须是main,方法必须是public static void 类型的,方法必须接收一个字符串数
    组的参数等等。
    ava 中args一般存在main主类方法内,String args[ ]或者String[ ] args表示给主方法传一个字符串数组. 而args是一个字符串数组的变量名,不是关键字,是arguments的缩写,只是一个默认名
     */
    public static void main(String[] args){
    
    
        //字符串常量
        System.out.println("中国");
        System.out.println("30");
        System.out.println("-20");
        //双引号中间可以为空
        System.out.println("");
        //浮点型常量
        System.out.println(3.2);
        //整型常量
        System.out.println(30);
        //字符常量,单引号内只能有一个字符
        System.out.println('3');
        System.out.println('A');
        System.out.println('a');
        System.out.println('中');
        //布尔常量,只能是 true 和 false
        System.out.println(true);
        System.out.println(false); 
        //空常量 null 不能直接打印输出,所以不展示了       
    }
}
执行结果
中国
30
-20

3.2
30
3
A
a
中
true
false

Data type understanding

Basic data types:
four types of strings, eight types,
integer type byte, short, int, long
floating point type float, double
character
type char Boolean type Boolean

Insert picture description here
Reference data types (not yet learned)
Strings, arrays, classes, interfaces, Lambda
notes:
1. Strings are not basic types, but reference types
2. Floating-point types may only be approximate values, not exact values
3. The data range is not necessarily related to the number of bytes. For example, the data range of float is wider than long, but float is 4 bytes, and long is 8 bytes.
4. Floating point numbers use double by default. If you must use float type, add a suffix
If F is an integer, the int type is used by default. If the long type must be used, a suffix L must be added

Guess you like

Origin blog.csdn.net/Ora_G/article/details/108356926