Java Basics--Sunshine always comes after the storm, please believe in the rainbow

1. Today’s task

  • JAVA SE-Han Shunping video tutorial – 30p or more (today it is 50p or more because it is the basics)
  • Summary of basic computer eight-part memory
  • To answer the questions (two questions), you can use python first

1、SSM

ssm->Spring (lightweight text development framework)/SpringMVC (layered web development framework)/MyBatis (persistence framework)

2. What is a program?

Program: A collection of ordered instructions written by a computer to perform some operation or solve a problem.

3. gosling, the father of java

4. The first version of Java was released in 1995

5. Java technology system platform

  • Java SE Standard Edition (supports the Java platform for desktop applications and provides a complete Java core API)
  • Java EE Enterprise Edition (a set of solutions for developing applications in an enterprise environment, mainly targeted at Web application development)
  • Java Me small version (a platform that supports Java programs running on mobile terminals, simplifies the Java API, and adds support for mobile terminals)

6. Important features of Java

  • The Java language is object-oriented (oop)
  • The Java language is robust. Java's strong typing mechanism, exception handling, automatic garbage collection, etc. are important guarantees for the robustness of Java programs.
  • The Java language is cross-platform. (That is, a compiled .class file can be run on multiple systems)

Java cross-platform

  • Java language is interpreted

Interpreted language: Javascript, PHP, java Compiled language: c/c++

The difference is: interpreted language, the compiled code cannot be directly executed by the machine, and needs an interpreter to execute. Compiled language, the compiled code can be directly executed by the machine, c/c++

7. Java operating mechanism and operating process

Insert image description here

  • Java core mechanism-Java virtual machine [JVM java virtual machine]
  1. JVM is a virtual computer that has an instruction set and uses different storage areas. Responsible for executing instructions, managing data, memory, registers, included in JDK
  2. For different platforms, there are different virtual machines
  3. The Java virtual machine mechanism shields the differences in underlying operating platforms and achieves "compile once, run anywhere"

Insert image description here

8. What is JDK, JRE

  • Basic introduction to JDK
    1. The full name of JDK (Java Development Kit Java Development Kit) JDK = JRE + java development tools [java, javac, javadoc, javap, etc.]
    2. JDK is provided for Java developers to use, which includes Java development tools, including JRE. So after installing JDK, you don’t need to install JRE separately.
  • Basic introduction to JRE
    1. JRE (Java Runtime Environment Java Runtime Environment) JRE = JVM + Java's core class library [class]
    2. Including Java Virtual Machine (JVM Java Virtual Machine) and the core class libraries required by Java programs. If you want to run a developed Java program, your computer only needs to install JRE.
  • Inclusion relationship between JDK, JRE and JVM
    1. JDK = JRE + development toolset (such as Javac, Java compilation tools, etc.)
    2. JRE = JVM + Java SE Standard Class Library (Java Core Class Library)
    3. If you just want to run the developed .class file, you only need JRE

9. Configure the environment variable path

  • Steps to configure the environment variable path
  1. My Computer – Properties – Advanced System Settings – Environment Variables
  2. Add the JAVA_HOME environment variable to point to the jdk installation directory
  3. Edit the path environment variable and add %JAVA_HOME%\bin
  4. Open the DOS command line and type javac/java in any directory. If javac parameter information appears, the configuration is successful.
  5. User variables are similar to system variables except that the former only applies to the current user and the latter applies to all users.

10. Quick Start with Java

//这是java快速入门,演示java的开发步骤
//对代码的相关说明
//1、public class Hello 表示Hello是一个类,是一个public的类(公有)
//2、Hello{}表示一个类的开始和结束
//3、public static void main(String[] args) 表示一个主方法,即我们程序的入口
//4、main(){}表示方法的开始和结束
//5、System.out.println("hello,world~");表示输出"hello,world"到屏幕上
//6、; 表示语句结束
public class Hello {
    
    
	//编写一个main方法
	public static void main(String[] args) {
    
    
		System.out.println("亦向枫 is studying java!");
	}
}

How to deal with files in Chinese

Go to File->Set File Encoding->GBK and just save it again.

Running is to load the corresponding .class file (bytecode file) into the corresponding virtual machine and run it (.java file is the source file)

What is compilation:

1、有了java文件,通过编译器将其编译成JVM可以识别的字节码文件
2、在该源文件目录下,通过javac编译工具对Hello.java文件进行编译。本质就是将.class装载到JVM机执行
3、如果程序没有错误,没有任何提示,但在当前目录下会出现一个Hello.class文件,该文件称为字节码文件,也是可以执行的java的程序

11. Java development precautions and details

  1. Java source files have the extension name .java. The basic component of the source file is the class, such as the Hello class in this class
  2. The execution entry point of a Java application is the main() method. It has a fixed writing format: public static void mian (String[] args) {…}
  3. Java language is strictly case-sensitive.
  4. Java methods are composed of statements, each statement ends with ";"
  5. Braces appear in pairs, and neither one can be missing. [Habit, write {} first and then write code]
  6. There can be at most one public class in a source file, and there is no limit to the number of other classes. (After compilation, each class corresponds to a .class)
  7. If the source file contains a public class, the file name must be named after the class name
  8. There can be at most one public class in a source file. There is no limit to the number of other classes. You can also write the main method in a non-public class, and then specify to run the non-public class, so that the entry method is the non-public main method.

12. Java escape characters

  1. \t: A tab stop to realize the alignment function
  2. \n: newline character
  3. \ \ :one\
  4. \":a"
  5. \ ' :one'
  6. \r: A carriage return System.out.println("Yi Xiangfeng\rCome on");
//演示转义字符的使用
public class ChangeChar {
    
    

	//编写一个main方法
	public static void main(String[] args) {
    
    
		System.out.println("亦向枫\t刘妍汐");
		System.out.println("亦向枫\n刘妍汐");
		System.out.println("亦向枫\\刘妍汐");
		System.out.println("亦向枫\"刘妍汐\"");
		System.out.println("亦向枫\'刘妍汐\'");
		System.out.println("亦向枫加油\r刘妍汐");
		//解读
		//1、输出:亦向枫
		//2、\r表示回车
		//光标回到最前面并开始打印,结果为:刘妍汐加油
		System.out.println("亦向枫加油\r\n刘妍汐加油");
	}
}
结果为:

亦向枫  刘妍汐
亦向枫
刘妍汐
亦向枫\刘妍汐
亦向枫"刘妍汐"
亦向枫'刘妍汐'
刘妍汐加油
亦向枫加油
刘妍汐加油

practise:

Requirement: Please use an output statement to achieve the effect of inputting the following image

The external link image transfer failed. The source site may have an anti-leeching mechanism. It is recommended to save the image and upload it directly.

public class ChangeChar {
    
    

	//编写一个main方法
	public static void main(String[] args) {
    
    
		System.out.println("书名\t作者\t价格\t销量\n三国\t罗贯中\t120\t1000");
	}
}

13. It’s easy to make mistakes when learning Java for beginners

  1. File not found (solution: the source file name does not exist or is written incorrectly, or the current path is wrong)
  2. The main class name and the file name are inconsistent (solution: the main class declared as public should be consistent with the file name, otherwise the compilation fails)
  3. Missing semicolon (solution: compilation fails, pay attention to the number of lines where the error occurs, and then correct the error at the specified location in the source code)

The external link image transfer failed. The source site may have an anti-leeching mechanism. It is recommended to save the image and upload it directly.

14. Annotation types in Java

  1. Single line comments (//comment text)
  2. Multi-line comments (/* comment text */)
  3. Documentation comments

Usage details:

  1. The commented text will not be interpreted and executed by the JVM (Java Virtual Machine)
  2. Nesting of multi-line comments is not allowed within multi-line comments

Documentation comments: The comment content can be parsed by the javadoc tool provided by the JDK to generate a set of documentation comments that embody the program's documentation in the form of a web page.

Javadoc -d folder name -xx -yy source file name

javadoc tag

The javadoc utility recognizes the following tags:

Label describe Example
@author Identify the author of a class @author description
@deprecated Name an out-of-date class or member @deprecated description
{@docRoot} Specifies the path to the current document root directory Directory Path
@exception Flags an exception thrown by a class @exception exception-name explanation
{@inheritDoc} Annotations inherited from direct parent class Inherits a comment from the immediate surperclass.
{@link} Insert a link to another topic {@link name text}
{@linkplain} Insert a link to another topic, but the link displays a text-only font Inserts an in-line link to another topic.
@param Describe the parameters of a method @param parameter-name explanation
@return Describe return value type @return explanation
@see Specify a link to another topic @see anchor
@serial Describes a serialization property @serial description
@serialData Describes data written through the writeObject() and writeExternal() methods @serialData description
@serialField Describes an ObjectStreamField component @serialField name type description
@since Flag when a specific change is introduced @since release
@throws Same as @exception tag. The @throws tag has the same meaning as the @exception tag.
{@value} Displays the value of a constant, which must be a static property. Displays the value of a constant, which must be a static field.
@version Specify the version of the class @version info

15. Java code specifications

  1. Comments on classes and methods must be written in javadoc.
  2. Non-Java Doc comments are usually for the maintainers of the code. They focus on telling readers why they are written this way, how to modify them, what issues to pay attention to, etc.
  3. Use the tab operation to achieve indentation. By default, the entirety moves to the right. Use shift+tab to move the entirety to the left.
  4. It is customary to put a space on both sides of the operator and =. For example: 2 + 5 * 4 + 345 - 89
  5. The source file is encoded using utf-8
  6. Line width should not exceed 80 characters
  7. Code writing sub-line style and end-of-line style

The external link image transfer failed. The source site may have an anti-leeching mechanism. It is recommended to save the image and upload it directly.

2. Today’s summary

  • Task summary
    • I studied a question, but it was like I didn’t study it, didn’t summarize it, and didn’t look at it more.
    • Learn the basics of Java by watching videos and taking notes. The progress is too slow at less than 30p.
    • I will read the interview questions in the evening
  • Planning for tomorrow
    • Learn Java basics, watch videos and take notes—30p and above
    • Answer at least one question and make a summary
    • At least one interview question or an interview question blog (take notes)

Guess you like

Origin blog.csdn.net/weixin_53909748/article/details/133837931