First knowledge of Java

Source: Internet
Author: User

History of computer languageMachine Language

every computer can only understand his own machine language. Machine language is a natural language for a computer, defined by the designer of a computer's hardware. Machine language is usually made up of digital strings (which are ultimately simplified into the same), and for humans, machine language is too cumbersome.

implementation of this task: basic costs (Basepay) + overtime charge (overpay) = Total cost (Totalpay)

Typical machine language:

Assembly Language

For the convenience of programming, and to solve more complex problems. programmers begin to use abbreviated mnemonics in English to denote basic computer operations. these mnemonics form the basis of assembly language.

Typical assembly language:

Advanced Language

For simple tasks, assembly language can be competent. But with the development of computers, infiltration into the work of more aspects of life, a number of complex tasks appear, assembly language appears to be limited (it should be said that programmers use assembly language to solve complex problems there is a bottleneck). So, a high-level language appeared. Like C,c++,java are high-level languages. High-level languages allow programmers to write programs that are close to everyday English instructions.

Grosspay = Basepay + overpay;

From the above simple addition calculation, it can be seen that the more high-level language, the closer to people's thinking, the more convenient for people to use.

Summarize:

The ultimate goal of all programming languages is to provide an "abstract" approach. The higher the level of abstraction, the closer the human mind is.

The ultimate goal of programming is to solve real-world problems!

A brief History of Java development

in 1991 ,James Gosling , a team of engineers at Sun , wanted to design such a small computer language. The language is used primarily for consumer electronics such as TV boxes, which have a common feature: Computational processing power and memory are very limited. So the requirement: the language must be very small and able to generate very compact code so that it can be executed in such an environment.

In addition, because different manufacturers choose different CPU, therefore, requires that the language cannot be tied to a particular architecture, requiring that the language itself be neutral, that is, cross-platform . So, name this language "green", similar to the meaning of green software.

later, renaming will OAK. The meaning of the oak. Renamed after the discovery of a language has been called this name, in a change called JAVA.

1991 ,Sun 's Green project,Oak

1995 , Java Beta release

1996 years,JDK1.0

1997 years,JDK1.1

1998 ,JDK1.2, greatly improved the previous version of the flaw, is a revolutionary version, renamed Java2.

2004 years,J2SE 5.0 (1.5.0) Tiger Tigers

2006 years,J2SE 6.0 (1.6.0) Mustang Mustang

What the Java versions mean

EE (Java 2 Enterprise Edition): Locating applications on the server side

J2SE (Java 2 standard Edition): Applications for positioning on personal computers

J2ME (Java Micro Edition): Positioning in the application of consumer electronic products

features and benefits of Java

Simplicity of:

is the pure version of C + + syntax. There are no header files, pointer operations, structs, unions, operator overloads, virtual base classes, and so on. Because the grammar is based on C, it is completely effortless to learn.

Object-oriented:

Object-oriented is a programming technique that focuses on the interface between data (that is, objects) and objects.

Portability:

this is one of the important advantages of JAVA. JAVA code or bytecode, binary code can be ported across platforms, without the need for a specific operating system and hardware environment. JAVA itself is network-oriented, only in the network environment in order to show his advantages, such as: Now I have a network environment, to let my notebook and mobile phone interaction, notebook environment is Windows A JAVA code to make a regular recording of the phone , the phone only a simple Linux kernel operating system, can still execute this code perfectly.

Write once, run anywhere:write once, run anywhere

JAVA is designed with a focus on porting and cross-platform. For example: the Int of JAVA is always the first digit. unlike C + + , which may be in the following, thechanges may be based on the compiler manufacturer's requirements. In this case, the transplant of the program will be very troublesome.

Performance:

JIT (JUST in time) is compiled immediately. Compile some "hot" bytecode into the cost of the machine code and cache the results and recall them when needed. In this way, the execution efficiency of JAVA programs is greatly improved, and some code even receives the efficiency of C + + . As the technology grows, it may one day surpass the efficiency of compiling code.

Distributed:

JAVA was designed for The distributed environment of the Internet because he was able to handle the TCP/IP protocol. In fact, Accessing a network resource through a URL is as simple as accessing a local file. Java also supports remote method calls (Rmi,remote methods invocation)toenable programs to invoke methods over the network.

Dynamic nature:

is to add some code to the running program when needed. Reflection mechanism. Dynamic is a very important feature when you need to add some code to a running program. The dynamic nature of Java is an extension of its object-oriented design approach. It allows the program to dynamically load the required classes during the run, which is not possible with the C + + language for object-oriented programming.

Multithreading:

The use of multithreading can lead to better interactive responses and real-time behavior. The simplicity of multithreading is one of the main reasons why Java has become a mainstream server-side development language.

Security:

Java is suitable for the network / Distributed environment, in order to achieve this goal, the security has invested a lot of effort to make

Java can build anti-virus, tamper-proof systems.

Robustness:

Java is a robust language that absorbs the advantages of the C + + language, but removes the parts that affect the robustness of the program (such as pointers, memory applications and releases, etc.). Java programs cannot cause a computer crash. The Java system carefully detects every access to memory, confirms that it is legitimate, and does not cause any problems. However, even Java programs may have errors. If something unexpected happens, the program does not crash, but discards the exception. Through the exception handling mechanism, the program will find such exceptions and deal with them.

running mechanisms for Java applications

High-level programming language types for computers: compiled , interpreted

The Java language is a combination of two types;

Use the editor to write Java source - source file name: Main class name . Java

Use the compiler (Javac) to compile the source program into bytecode - byte-code file name: source file name . class

Use the virtual machine (interpreter,Java) to interpret the execution :

Running Process: loading, code validation, interpreting execution

Java Cross-platform core JVM

A JVM is a specification that can be implemented using software or hardware , a virtual computer that executes bytecodes bytecode. He also defines the instruction set, register set, structure stack, garbage collection heap, memory area.

The JVM is responsible for running the Java bytecode interpretation and running the side interpretation, so that the speed will be affected. JAVA provides another way to explain how to run JIT(justin time), which can be explained at once , and then run the machine code on the specific platform, the advanced The JIT can only analyze hot spot code, and turn the code into local machine code, and cache the results, the next time directly from memory calls, which greatly improves the efficiency of executing JAVA code. This enables cross-platform, portable functionality.

    1. A JVM is a computer that is emulated by software or hardware on a single computer; it resembles a small, efficient CPU.
    2. The Byte-code code is a platform-independent machine instruction for a virtual machine.
    3. the Java byte code runs in two ways :

1) mode Interpreter ( explanation )

2) Just-in-time ( Instant compile ): There is a code generator that converts the byte code into the machine code of the machine , which can then be executed at a higher speed.

Different operating systems have different virtual machines. The Java virtual machine mechanism masks the difference between the underlying operating platform, enabling "one-time compilation, running Anywhere".

Common DOS Commands
    1. CD into a directory
    2. Cd.. Back to previous directory
    3. Dir viewing a document in a folder
    4. Up and down keys: Find the command you've knocked over
    5. Tab key: auto-completion command

summary and promotion of the first Java program

* Java is case sensitive and the program cannot run if there is a case spelling error.

* The keyword public is referred to as the access modifier (accessmodifier), which is used by other parts of the control program to access the code.

* The keyword class indicates that all content in a Java program is contained in a class, andjava is a purely object-oriented language.

* A source file can have at most one public class declaration, the number of other classes are unlimited , if the source file contains a public class, the source filename must and it is defined in the public The class name is the same, with "java" as the extension.

* One source file can have more than one class

* properly compiled source files, will be the corresponding bytecode files, the compiler generates a separate bytecode file for each class, and the bytecode file is automatically named class name and "class" as the extension.

* The main method is the Java application's entry method , which has a fixed writing format: public static void Main (string[] args) {... }

* in Java , the various parts of the program are separated by curly braces, and the code of any method must begin with "{"and end with "}". the curly brace style is unrestricted because the compiler ignores spaces .

* Each statement in Java must end with a semicolon , and the carriage return is not the end flag of the statement, so a statement can span multiple lines.

Programming Style :

    1. Attention Indent !
    2. programming in Pairs !

First knowledge of Java

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.