Basic knowledge of Java [1]

A deeply touching sentence: Instability is a weak foundation, and ignorance is lack of knowledge. This article is written to allow myself to consolidate the basic knowledge, and I hope to keep writing.



1. The core concepts of JDK, JRE, and JVM

  • The concept of
    JVM (Java Virtual Machine), Java virtual machine (java can be cross-platform).
    JRE (Java Runtime Environment), the Java runtime environment, includes the JVM and Java's core class library (Java API).
    JDK (Java Development Kit) is called the Java Development Kit, which includes JRE and development tools (compilation tools and running tools).
  • relationship between the three
    Relationship diagram of JDK, JRE, and JVM

2. Configure environment variables

  • Why configure
    the Java-related commands in the bin directory to be used in any directory (it can also be understood in this way, run java, javac commands anywhere).
  • how to configure

jdk configuration path environment steps

3. The process of solving bugs

  • Have the ability to identify BUG and read more error messages
  • Have the ability to analyze bugs: think more, consult more information.
  • Have the ability to solve bugs: try more, summarize more.

Fourth, Java basic grammar [1]

1. Notes

  • Single-line comment
    The format of a single-line comment is to use //, and the text from // to the end of the line will be used as the comment text.

     // 这是单行注释文字
    
  • Multi-line comments
    The format of multi-line comments is to use /* and */ to enclose a long comment.

    /*
    这是多行注释文字
    这是多行注释文字
    */
    

    Note: Multi-line comments cannot be nested.

  • Documentation comments
    Documentation comments /**begin with and */end with

    /**
    1.具备识别bug的能力:多看报错信息。
    2.具备分析bug的能力:多思考,多查阅资料。
    3.具备解决bug的能力:多尝试,多总结。
    */
    

2. Keywords

  • Words given special meaning by the Java language. Keyword letters are all lowercase.
  • 例如, public class static void
     // 关键字在代码编辑器中一般都会高亮显示,例如:
     public class static void   
     // 不是关键字,例如:
     main String System
    

3. Constants

  • During the execution of the program, its value will not change (the focus is on the value , fixed and specific value)
constant type illustrate example
string constant Enclosed in double quotes "Hello World", "Hello World"
integer constant numbers without decimals 666,-88
decimal constant numbers with decimals 13.14,-5.21
character constant Enclosed in single quotes 'A', '0', 'Man'
boolean constant Boolean value, indicating true or false Only two values: true, false
empty constant a special value, null Value is: null

4. Variables

  • A variable is a storage space in memory that stores frequently changing quantities (data)
  • Amount that can be changed (focus on storage space, variable name)
  • The format of defining variables: data type variable name = data value;
    String name = "小明";
    
  • Note
    1. Variable names are not allowed to be defined repeatedly.
    2. A statement can define multiple variables separated by commas.
    3. Variables must be assigned before use.
    4. Precautions for defining float and long variables (you need to use f or F, l or L to identify the type of constant), if long is not added, no error will be reported, but it is recommended to add L.
    5. The scope of the variable (scope: the scope wrapped by {} is called the scope, and variables in java only take effect in their own scope).

to be continued

The above is the content of this article. The basic Java grammar [2] will continue to be written in the next article. There are also many important knowledge points in the Java foundation, which will be summarized in the next article.

Guess you like

Origin blog.csdn.net/qq_45337268/article/details/126842482