Java basic notes (introduction)

1.1 JAVA language

An object-oriented language

A platform-independent language, an interpretation environment where the program must run

A robust language that absorbs the advantages of the C/C++ language, but removes the parts that affect the robustness of the program, such as pointers, memory application and release, etc.

1.1.2 The core advantage of JAVA .

The java language trades high security at the expense of execution efficiency

1.1.3 Advantages and Features of JAVA

Cross-platform/portability

This is the core advantage of Java. Java is designed with great emphasis on portability and cross-platform. For example: Java int forever

Both are 32 bits. Unlike C++, it may be 16, 32, which may be changed according to the compiler manufacturer's regulations. In this case, the program

Transplantation will be very troublesome.

 Security

Java is suitable for network/distributed environment. In order to achieve this goal, a lot of energy has been invested in security.

Make it easy for Java to build an anti-virus and anti-tampering system.

 Object-oriented

Object-oriented is a programming technology, very suitable for the design and development of large-scale software. Since C++ takes care of the big

C language users are compatible with C, making itself only a C language with classes, which affects its object-oriented

The thoroughness! Java is a completely object-oriented language.

 Simplicity

Java is a simplified version of C++ syntax, we can also call Java "C+±". Say "C plus plus minus" to me,

Refers to removing some of the contents of C++; for example: header files, pointer arithmetic, structure, union, operator overloading, virtual

Base class and so on. At the same time, because the grammar is based on the C language, it is completely effortless to learn.

 High performance

In the initial development stage of Java, it was always criticized as "low performance"; objectively, high-level language operating efficiency is always lower than low-level

Language, this cannot be avoided. The optimization of the virtual machine in the development of the Java language itself has improved the operating efficiency by dozens of times. ratio

For example, through JIT (JUST IN TIME) just-in-time compilation technology to improve operating efficiency. Compile some "hot" bytecodes into local

Machine code, and cache the results, and recall them when needed. In this way, the execution efficiency of the Java program

Greatly improve the efficiency of some codes and even C++.

Therefore, the short legs of Java's low performance have been completely resolved. In the development of the industry, we have also seen many C++ applications

By switching to Java development, many C++ programmers have transformed into Java programmers.

 Distributed

Java is designed for the distributed environment of the Internet because it can handle the TCP/IP protocol. In fact, through

URL access to a network resource is as simple as accessing local files. Java also supports remote method invocation (RMI,

Remote Method Invocation), which enables programs to call methods through the network.


Multithreading The use of multithreading can bring better interactive response and real-time behavior. The simplicity of Java multithreading is what Java becomes

One of the main reasons for mainstream server-side development languages.

 Robustness

Java is a robust language that absorbs the advantages of the C/C++ language, but removes the part that affects the robustness of the program

Points (such as pointers, memory application and release, etc.). The Java program cannot cause the computer to crash. Even if the Java program

There may also be errors. If something unexpected happens, the program will not crash, but throw the exception and pass

Exception handling mechanism to deal with it.

1.2 Develop and run the first JAVA program

1.2.1 The first JAVA program

public class Hello{其中public class是系统定义的关键字,Hello是用户自定义的类名称,
要求必须和文件名称一致,包括大小写,{}中用于用户自定义程序
public static void main(String[] args){//这个方法的名称不允许作任何调整,包括大小
写,这是程序的执行起始点
   System.out.println("Hello Java!");在Java中语句以;收尾,System.out.println
用于实现在屏幕上输出字串内容,所谓的字串就是引号中所包含的字符序列
}    
}

1.2.2 Summary and improvement of the first program

Java is an object-oriented programming language. The beginning of writing a program is the beginning of defining classes

Public is a public class, there can be multiple classes in a java program, but there can only be one public class

The java file name is consistent with the class name

1.2.3 The most commonly used DOS commands

DOS commands have basically withdrawn from the historical stage of ordinary users, but we still need to master several commonly used commands

In order to facilitate smoother operating procedures in some cases, Java is strictly case-sensitive, which means that the correct file name must be entered when operating, but in the windo10 system, the corresponding letter is sufficient.

  1. cd directory path to enter a directory
  2. cd… enter 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 commands you have typed
  6. Tab key to automatically complete commands

1.2.4 java syntax basis

Java is a free-form language, you can use any number of spaces, tabs, and newlines to separate each word

Each piece of code ends with ";"

Guess you like

Origin blog.csdn.net/qq_45874107/article/details/109379599