01 JavaSE basic syntax
java introduction
Java is a derived language. Early language designers did not want to use C++ in their projects and created this new language that looks a lot like C++, but has improvements over C++ (the original project was not successful). The core change of Java is the addition of "virtual machine" and "garbage collection mechanism". These two concepts will be described in detail in later chapters. In addition, Java has also promoted the development of the industry in other ways. For example, most programming languages now support document comment syntax and HTML document generation tools.
The meaning of each version of java
In short, javase is the foundation and must be learned first; javaee is enterprise-level, then learn, and then you can move to the direction of javaweb, javame is for mobile applications. The basics must be learned first, and then consider the next step. There are three versions of the Java platform, which allows software developers, service providers, and equipment manufacturers to develop for specific markets.
J2EE (Java 2 Enterprise Edition): an application positioned on the server side
J2EE is an extension of J2SE, adding a class library for server development. For example: javax.servlet Enterprise JavaBeans is a software component used to represent enterprise logic; JDBC allows programmers to directly use SQL syntax in Java to access data in the database; Servlet can extend the function of the server through Request-response mode is used to process client requests; JSP is a technology that can embed Java program code in web pages; in addition, there are various server-side APIs including XML, email, and transaction.
J2SE (Java 2 Standard Edition): an application positioned on a personal computer
This version is the core of the Java platform. It provides a very rich API to develop applications on general personal computers, including user interfaces AWT and Swing, network functions and internationalization, image processing capabilities, and input and output support. Applet that shines on the Internet also belongs to this version.
J2ME (Java Micro Edition): Positioned in the application of consumer electronic products
J2ME is an extension of J2SE, including part of the core classes of J2SE, and also has its own extension classes, adding those suitable for small devices
Class library: javax.microedition.io.* etc.
Java features and advantages
Simplicity, object-oriented, portability, high-performance dynamics, multi-threaded safety, robustness
Operating mechanism of java application
Computer high-level language type: compiled and interpreted
jvm virtual machine
JVM is a specification that can be implemented using software or hardware. It is a virtual computer used to execute bytecodes. He also defines the instruction set, register set, structure stack, garbage collection heap, and memory area. JVM is responsible for interpreting and running the java bytecode, and running while interpreting, the speed will be affected to a certain extent. JAVA provides another method of interpreting and running, JIT (just in time), which can be explained once, and then run the machine code on a specific platform. Advanced JIT can only analyze hot codes and convert these codes to local machine codes , And cache the result, and call it directly from the memory next time, which greatly improves the efficiency of executing JAVA code. In this way, a cross-platform, portable function is realized.
-
JVM refers to a computer emulated by software or hardware on a computer; it is similar to a small and efficient CPU.
-
The byte-code code is the machine instruction of the virtual machine that has nothing to do with the platform.
-
There are two ways of running java byte code: interpreter (interpretation) Just-in-time (just-in-time compilation): There is a code generator that converts the byte code into native machine code, which can then be executed at a higher speed.
Different operating systems have different virtual machines. The Java virtual machine mechanism shields the difference between the underlying operating platforms and realizes "compile once, run anywhere".
jre runtime environment
Java Runtime Environment (JRE) includes: Java virtual machine, library functions, necessary files for running Java applications and Applet
Three main functions of the Java runtime environment:
-
Loading code: completed by class loader;
-
Verification code: completed by bytecode verifier;
-
Code execution: completed by runtime interpreter.
jdk development kit
SDK (Soxware Development Kit) (also known as jdk) is a superset of jre, which adds a compiler and other development tools on the basis of jre. jre is the java runtime environment, including jvm and some other java core apis. Any computer can run java programs only if jre is installed.
Java2SDK (Development Kit) contains: a superset of JRE, including files used for program development such as compilers and debuggers.
So running java files only needs jre. But to develop java programs, jdk is needed.
Basic grammar
Class {property method}: a summary of things abstract overall
Special method {constructor} assigns attributes to things
Attribute {simple type complex type} the necessary characteristics of things themselves
Method {method permission method signature} the functional capabilities of things
Interface {abstract method implementation function}
Enum {enum property}
Simple type:
Complex type: data type object address reference after boxing
Boxing: Encapsulate data into classes
Unboxing: unboxing the class to read out the data
this super
public default protect private
static { } final
Upward transformation Downward transformation
Logical budget
Ternary operator
for while do{ }while if eles switch
continue break return