[Java Getting Started note] Introduction to the Java language

Source: Internet
Author: User

Objective

Java has been learning for some time, but has been missing a system of thought, and now re-through books, online articles, videos and other materials, collation and review of Java knowledge points.

To get started, let's start with understanding the Java language.

The origin of the Java language

Java is a generic term for the Java object-oriented programming language (hereinafter referred to as the Java language) and the Java platform introduced by Sun Microsystems Corporation. Co-developed by James Gosling and co-workers, and was formally launched in 1995. Originally known as Oak, Java was designed for embedded chips in consumer electronics in the 1991. Renamed Java in 1995 and redesigned to develop Internet applications. Java-enabled HotJava browser (Java applet support) shows the charm of Java: Cross-platform, dynamic web, Internet computing. Since then, Java has been widely accepted and promoted the rapid development of the web, commonly used browsers support Javaapplet. Java technology, on the other hand, is constantly being updated. Since the advent of Java is very popular, rapid development, the C + + language to form a strong impact. In the global cloud computing and mobile Internet industry environment, Java has a significant advantage and broad prospects. [citation from Baidu Encyclopedia]

The Java language Features advantages

1, simple.

The syntax of the Java language is close to the C and C + + languages, making it easy for most programmers to learn and use Java. Java, on the other hand, discards those features that are seldom used, difficult to understand, and confusing in C + +. Removed many complex features in C and C + +, such as pointers, operator overloads, multiple inheritance, automatic coercion type conversions, no goto statements, no struct and union, etc. In particular, the Java language does not use pointers and provides automatic scrap collection, which makes it unnecessary for programmers to worry about memory management.

2, object-oriented.

Object-oriented can be said to be the most basic feature of Java. The Java language is designed to be completely object-oriented, and it does not support process-oriented programming techniques like the C language. All Java programs and applets are objects, and Java supports code inheritance and reuse in both static and dynamic styles. It is more thorough and more pure than C + +. The Java language provides primitives such as classes, interfaces, and inheritance, and for simplicity, only single inheritance between classes is supported, but multiple inheritance between interfaces is supported, and the implementation mechanism between classes and interfaces is supported (the keyword is implements).

3, cross-platform nature.

Platform agnostic is the biggest advantage of the Java language. A major problem with programs written in other languages is the changes in operating systems, processor upgrades, and changes in core system resources, which can cause programs to fail or run out of control. Java's virtual machine successfully solves this problem, and Java-written programs can run correctly on any computer where the Java Virtual machine JVM is installed, and Sun realizes its own goal "write once, run everywhere"

The specific performance is:

    • Structurally neutral: Java programs (files with the suffix Java) are compiled on the Java platform into an architecture-neutral bytecode format (a file with a suffix of class) that can then be run on any system that implements the Java platform. This approach is suitable for heterogeneous network environment and software distribution.
    • Portable: This portability comes from architecture neutrality, and Java also strictly specifies the length of each basic data type. Java system itself is also very strong portability, Java compiler is implemented in Java, Java operating environment is implemented with ANSI C.
    • Interpreted: Java programs are compiled into bytecode format on the Java platform and can then be run on any system that implements the Java platform. At runtime, these bytecode are interpreted by the Java interpreter in the Java platform, and the classes required during execution are loaded into the runtime environment during the join phase.

4, robust.

Java's strong typing mechanism, exception handling, and automatic collection of scrap are important guarantees of Java program robustness. Discarding pointers is a wise choice for Java. Java's security check mechanism makes Java more robust.

5, security.

As a network language, security is very important. Java security can be guaranteed in two ways. On the one hand, in the Java language, C + + functions like pointers and freeing memory are removed to avoid illegal memory operations. On the other hand, when Java is used to create a browser, the language features are combined with the functionality provided by a class of browsers to make it more secure. The Java language is tested many times before it is executed on your machine. It is checked by code, checks the format of the code snippet, detects pointer manipulation, whether the object is manipulated excessively, and attempts to change the type of an object. In addition, Java has multiple levels of interlock protection, can effectively prevent the virus intrusion and destruction behavior.

6, multi-threaded.

In the Java language, a thread is a special object that must be created by the thread class or its child (grandchild) class. There are usually two ways to create a thread: one is to wrap an object that implements the Runnable interface into a thread using a constructor of type thread (Runnable), and another to derive a subclass from the thread class and override the Run method, and the object created with that subclass is a thread. It is important to note that the thread class has implemented the Runnable interface, so any thread has its run method, and the Run method contains the code that the thread wants to run. The activity of a thread is controlled by a set of methods. The Java language supports simultaneous execution of multiple threads and provides a synchronization mechanism between multithreading (the keyword is synchronized).

7, dynamic.

One of the design goals of the Java language is to adapt to dynamically changing environments. The classes required by the Java program can be dynamically loaded into the runtime environment, or they can be loaded into the network to load the required classes. This also facilitates software upgrades. In addition, classes in Java have a run-time representation that enables type checking at run time.

Disadvantages

Of course, all things can not be perfect, there are some advantages will inevitably have shortcomings.

1, efficiency: Because to first through the compilation and garbage collection mechanism, so the speed is relatively slow! Not suitable for large-scale programs, network games and other programming!

2, complexity, because it is powerful, so also increased its complexity, like today's popular framework has a lot of, what struts,spring,jquery and so on, undoubtedly increased the complexity of Java.

Operating mechanism of Java other high-level languages

Computer high-level language can be divided into compiled and interpreted according to the way of program execution.

Compiled language refers to before the execution of the program, there will be a separate compilation process, for a specific platform (operating system), the high-level language translated into machine language, the later implementation of the program, you can run directly, so that the compilation can be run independently from the development environment, the efficiency can be higher. However, there is also a disadvantage, that is, the compilation language is compiled into the machine code on a specific platform, usually can not be transferred directly to other platforms to run, if there is a need to re-transfer the source code to a specific platform, modified for some platform after the recompile. C + +, etc. are compiled languages.

Interpreted language refers to the translation of programs into machine language at run time, which is better cross-platform, but the disadvantage is that each execution needs to be compiled once. It is equivalent to mixing the compilation and interpretation processes in a compiled language together. Ruby,python and so on are interpreted languages.

The operation mechanism of Java program

The Java language is special, and programs written in the Java language need to be compiled, except that it is not a machine code compiled into a specific language, but rather a machine-independent bytecode (*.class file). This bytecode cannot be run directly and needs to be run through the Java interpreter (JVM Java Virtual machine). Therefore, the Java language is compiled first, then explained, separating the two steps.

JVM Virtual Machine

As described above, the Java program requires a JVM virtual machine to run bytecode, so let's take a look at it.

Java Virtual machine, which is the JVM (Java Vsan). When the Java compiler compiles Java code, the JVM-oriented bytecode is generated, and the JVM is oriented to the operating system, so programs written in the Java language are actually running on top of the JVM, rather than running on the operating system.

It has an interpreter component that enables the communication between Java bytecode and computer operating systems.

A JVM is similar to an abstract computer, and, like the actual computer, it has instruction sets and uses different storage areas. Complex execution directives that manage data, memory, and registers.

Java SDK JDK (Java Development Kit)

The JDK is the short name for the Java SDK and is a set of development packages that Sun provides for developing Java programs. It provides the tools and resources needed to compile and run Java programs. Contains Java compilers, Java runtime environments, common Java class libraries, and more.

Java Runtime Environment JRE (Java Runtime Environment)

JRE is a prerequisite for running Java programs, and the JRE contains JVM,JVM is the core virtual machine running Java programs, while running Java programs requires not only the core virtual machine, but also the class loader, bytecode checker and a large number of base class libraries, and the JDK also contains development tools, So if you just need to run a Java program, just install the JRE.

Sun divides Java into Java SE, Java EE, and Java ME.

    • J2SE (Standard Edition): Standards Edition, for the development of common applications;
    • Java Edition: Enterprise Edition, for the development of large enterprise-level applications;
    • J2ME (Mirco Edition): Miniature version for program development for mobile devices or embedded devices.

[Java Getting Started note] Introduction to the Java language

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.