2022.1.2Basic concepts of Java

Java Learning Route

Java Basics->Database Programming->Web Development->JAVAEE Development->SSM Framework->Access Control->Project Management and Linux->Distributed RPC Call and Distributed File Storage->Message Middleware->High Performance Data Processing NoSQL, sub-database and sub-table->full-text search service->SpringCloud micro-service technology stack->Alibaba micro-service technology stack->container technology

History of Java

In 1991, SUN wanted to design a small computer language. The language itself is required to be neutral and cross-platform.

SUN is currently acquired by Oracle Corporation.

The meaning of the three versions

JavaSE (Java standard edition) standard edition, for beginners

JavaEE (Java enterprise edition) Enterprise Edition

JavaME (Java micro edition) micro version

core advantages

Cross-platform, caught up with the initial development of the Internet, and developed with the development of the Internet.

At present, it still occupies the market and has established a strong ecosystem. At present, it has covered the "number one language" of various IT industries, and is the "English" of the computer industry.

Remaining advantages, features:

Security, object-oriented, simplicity (compared with c++), high performance (previously low performance, solved), distributed, multi-threaded, robust

Java program running mechanism

Source file---"compiler---"bytecode file (class file)---"JVM virtual machine---"operating system (Linux, Windows, Mac)

Computer high-level language types: compiled, interpreted

Compilation type: compile once, execute once

Interpretation type: compile a line of code, explain a line of code (probably meaning)

The Java language is a combination of two types

JVM、JRE、JDK

JVM A "virtual machine" for bytecode bytecode. Different operating systems have different versions of JVM, which shields the differences of the underlying operating platforms and realizes the core of cross-platform

 JRE Java runtime environment: Java virtual machine (JVM), library functions, etc.

JDK: JRE, compiler and debugger etc.

  •  If you just want to run Java programs or Java games like Minecraf, you only need JRE. The JRE is very small, which contains the JVM
  • If you want to develop Java programs, you need to install JDK.

Summary of the first program helloWord,

  1. Java is case sensitive
  2. The keyword class means class. Java is an object-oriented language, all code must be located inside the class
  3. After compiling the source file, the corresponding bytecode file is obtained, and the compiler generates an independent bytecode file for each class
  4. The main method is the entry method of the Java application, with a fixed format: 
    public static void main(String[] args){...}
  5. A source file can contain multiple classes
  6. Each statement must end with a semicolon, carriage return is not the end of the statement, so a statement can span multiple lines
  7. When programming, be sure to pay attention to the indentation specification
  8. When writing brackets and quotation marks, they must be written in pairs

Most Commonly Used DOS Commands

  1. cd into a directory
  2. cd .. into the parent directory
  3. dir View the list of files and subdirectories in this directory
  4. cls clear screen command
  5. Up and down keys to find the typed command
  6. tab key autocomplete command

Experience summary: quick start, quick actual combat, and problem solving in actual combat

note

The comment content will not appear in the bytecode file, and the Java compiler will skip the comment statement when compiling

In Java, according to the different functions of comments, there are single-line, multi-line, and document comments

  • single line comment

                Single-line comments begin with "//"

  • multiline comment

                Multi-line comment "/* comment content */" 

  • Documentation comments

                Documentation comments start with "/**" and end with "*/". The comments contain some explanatory text and javaDoc tags, which can help generate some api documents

identifier

  1. Must start with a letter, underscore, dollar sign "$"
  2. Other parts can be any combination of letters, underscores, dollar signs and numbers
  3. Case sensitive and unlimited length
  4. Cannot be a Java keyword

An identifier representing a class name: the first letter of each word is capitalized, such as Man, GoodMan

Identifiers representing methods and variables: the first word is lowercase, and the first letter is capitalized from the second word. We call it the "hump principle", such as eat(), eatFood()

Java does not use the ASCII character set, but the Unicode character set.

keywords

Keywords in Java are not allowed to be used as identifiers

variable

  1.  The essence of a variable is to represent an "operable storage space". The location of the space is determined, but the value placed in it is uncertain.
  2. The "corresponding storage space" can be accessed through the variable name, thereby manipulating the value stored in this "storage space".
  3. Java is a strongly typed language, every variable must declare its data type. The data type of a variable determines how much space the variable occupies. For example, a variable of type int occupies 4 bytes, 32 bits.

variable declaration

double salary;            //双精度浮点型 8字节 64位
long earthPopulation;     //长整型      8字节 64位
int age;                  //整型        8字节 64位

before fixing

public class TestVariable{
	public static void main(String[] args){
		int age = 18;
		int b;                //在程序中变量必须初始化
		int x=0,y=0,z=1;
		System.out.println(age);
		System.out.println(b);
		System.out.println(z );
	}
}

adjusted

public class TestVariable{
	public static void main(String[] args){
		int age = 18;
		int b;
		int x=0,y=0,z=1;
        b = 1;
		System.out.println(age);
		System.out.println(b);
		System.out.println(z );
	}
}

Variable classification: local variables, member variables, static variables

constant

Constants are generally represented by uppercase letters, and words are separated by underscores

public class TestConstant{
	public static void main(String[] args){
		final double PI = 3.14;  //常量一般用大写字母来表示,单词与单词之间用下划线隔开
                                 //如MAX_A
		PI = 3.1415;
	}
}

The compile time error is as follows

 In the above example, "3.14" is called a character constant, and PI modified by final is called a symbol constant

 type of data

 Note: The reference data type occupies four bytes, which stores the address of the object

operator

 bitwise operator

 Press ab and the two variables are relative up and down according to the position

And then every bit is the same and all 1 is 1, otherwise it is 0

Or two variables, as long as there is 1 in each bit, it is 1

XOR is two variables, each bit is the same as 1, and the difference is 0

negate, negate every bit

For each shift left, multiplied by 2

For each shift to the right, divide by 2 more

Guess you like

Origin blog.csdn.net/qq_41302243/article/details/122278140