Java Programming Overview - Summary/Notes

1. Java programming platform

In the book "Java Core Technology", Cay S. Horstmann (Cay S. Horstmann) and his co-author Gary Cornell describe J3) distributed AVA as follows:

"As a computer language, Java's advertising words are indeed a bit exaggerated. Of course, Java is indeed an excellent programming language. As a real programmer, using Java is undoubtedly a better choice. We think: Java It has the potential to be a great programming language, but it may be too late. Once a language is widely used, the problem of awkward compatibility with existing code is in front of people. "

Java is a complete platform with a vast library of reusable code and an execution environment that provides services such as security, portability across operating systems, and automatic garbage collection.

2. The 11 key terms of the Java white paper

The designers of Java have written an influential white paper (see www.oracle.com/technetwork/java/langenv-140151.html ) that explains how it was designed and how it was done.

They also published a short summary, organized by 11 key terms (see http://horstmann.com/corejava/java-an-overview/7Gosling.pdf ):

1) Simplicity

Mainly manifested in grammar, Java is a language very close to C++, and Java grammar is a "pure" version of C++ grammar, which eliminates many rarely used, difficult to understand, and confusing features in C++. Java has no header files, pointer arithmetic, structures, unions, operator overloading, virtual base classes, etc.

 The following is the calculation of the sum of the addition of two numbers -

 Here is the C++ sample code:

#include
int main() {
    int num1 = 5;
    int num2 = 10;
    int sum = num1 + num2;
    std::cout << "THe sum is: " << sum << std::endl;
    return 0;
}

Here is the sample code in Java:

public class SimpleJavaExample {
    public static void main(String[] args) {
        int num1 = 5;
        int num2 = 10;
        int sum = num1 + num2;
        System.out.printIn("The sum is: " + sum);
}

It can be seen that in terms of syntax, Java is more concise and clear than C++. Java uses keywords and agreed naming conventions to reduce symbols and redundant information in the code.

The flip side of Java's "simple" is "small". Java supports the development of software that can run independently on small machines.

2) Object-oriented

Object-oriented design is a programming technique, and in the Java world, everything is an object. It focuses on data (objects) and interfaces to objects. Use the library as an analogy: Suppose there are two readers, namely "object-oriented readers" and "non-object-oriented readers", and their task is to use the library to borrow books. Among them, "object-oriented readers" mainly pay attention to the catalog of the library, and choose suitable books according to their own interests and needs, followed by the environment and borrowing methods of the library; while "non-object-oriented readers" focus on books Library environment and borrowing methods.

Java is mostly about multiple inheritance and the simpler concept of interfaces.

3) Distributed

Java has a rich library of routines for handling TCP/IP protocols such as HTTP and FTP. Java applications can open and access objects on the Internet through URLs, as convenient as accessing local files.

4) Robustness

One of Java's design goals was to provide programmers writing in Java with multifaceted reliability. Java puts a lot of emphasis on early problem detection, late dynamic (runtime) detection, and elimination of error-prone situations.

5) Security

Java should be suitable for network/distributed environment. In order to achieve this goal, security is taken seriously. Antivirus and anti-tampering systems can be built using Java.

6) Architecture neutral

The Java compiler achieves architecture neutrality by generating bytecode instructions that are independent of a particular computer architecture. Well-designed bytecode can not only be easily interpreted and executed on any machine, but also can be easily dynamically converted into native machine code.

7) Portability

Class libraries that are part of the system define portable interfaces.

Except for the parts related to the user interface, all other Java libraries do support platform independence very well. Not only are programs portable, Java APIs are often of higher quality than native APIs.

8) Explanatory

The Java interpreter can directly execute Java bytecode on any machine that has been ported with the interpreter. (I don’t understand, can’t Python code be executed directly in the Python environment? Can’t all languages ​​be interpreted?)

9) High performance

Although the performance of interpreted bytecode is usually satisfactory enough, there are occasions when more performance is required. The bytecode can be dynamically translated (at runtime) into machine code for the specific CPU running the application.

10) Multithreading

Multithreading can lead to better interactive responsiveness and real-time behavior.

11) Dynamic

Java is designed to adapt to an evolving environment, and libraries are free to add new methods and instance variables without any impact on clients. Finding out runtime type information in Java is very simple.

 

Guess you like

Origin blog.csdn.net/shufenanbei/article/details/131727921