Traditional Culture Encyclopedia - Traditional culture - Is Java easy to learn?

Is Java easy to learn?

Java is an object-oriented programming language, which not only absorbs the advantages of C++ language, but also abandons the concepts of multiple inheritance and pointers that are difficult to understand in C++, so Java language has two characteristics: powerful function and simple use. As the representative of static object-oriented programming language, Java language perfectly realizes the object-oriented theory and allows programmers to conduct complex programming in an elegant way of thinking [1].

Java has the characteristics of simplicity, object-oriented, distributed, robustness, security, platform independence and portability, multithreading, dynamic and so on [2]. Java can write desktop applications, Web applications, distributed systems and embedded system applications [3].

Foreign name

Java language (a computer language, especially for creating websites)

The current company

oracle

launch time

1May, 995

quick

navigate by water/air

Programming development

language feature

principle of operation

Language foundation

language standard

Language specification

technology application

Study Guide

Pascal evaluation

Development history

In the 1990s, a single chip microcomputer system appeared in the hardware field. As soon as this low-cost system appeared, it immediately attracted the attention of people in the field of automatic control, because it can greatly improve the intelligence of consumer electronic products (such as TV set-top boxes, bread ovens, mobile phones, etc.). ). In order to seize the market opportunity, Sun Company set up a project team named Green at 199 1. Patrick, james gosling, Mike Xie Lidan and several other engineers worked together to develop new technologies in a small studio on Dune Road in Menlo Park, California, specializing in the embedded application of computers in household appliances.

Java language (a computer language, especially for creating websites)

Because of the advantages of C++, the researchers of the project team first consider writing programs in C++. However, the C++ program is too complicated and huge for a monolithic system with extremely scarce hardware resources. In addition, due to the wide variety of embedded processor chips used in consumer electronic products, how to make the programs run across platforms is also a difficult problem. In order to solve the difficulties, they first focused on language development, assumed a hardware platform architecture with simple structure and meeting the needs of embedded applications, and formulated corresponding specifications for it, in which the binary machine code instruction system of this hardware platform (that is, the instruction system that later became "bytecode") was defined, so that after the language development was successful, semiconductor chip manufacturers could develop and produce this hardware platform. For the design of new language, the staff of Sun Company did not develop a brand-new language, but reformed C++ according to the requirements of embedded software, removed some components that are not practical and affect security, and combined with the real-time requirements of embedded system, developed an object-oriented language called Oak.

Because there is no hardware platform to run bytecode when developing Oak language, in order to carry out experimental research on this language during development, they built an operating platform with software based on the existing software and hardware platforms and according to their own specified specifications. The whole system is simpler than C++, and there is not much difference. 1992 In the summer, when the Oak language was successfully developed, researchers demonstrated the green operating system, Oak programming language, class library and its hardware to hardware manufacturers, and persuaded them to use Oak language to produce hardware chips, but hardware manufacturers were not very enthusiastic about it. Because they think it is too risky to produce hardware products when everyone knows nothing about Oak language, Oak language has been shelved because it cannot enter the market because of lack of hardware support.

During June and July of 1994, after three days of discussion, the team decided to change the goal of their efforts again, and this time they decided to apply this technology to the World Wide Web. They believe that with the advent of mosaic browsers, the Internet is evolving to the highly interactive prospect they see in cable TV networks. As a prototype, Patrick Norton wrote a small web browser WebRunner. [4]

1995, the vigorous development of the Internet gives Oak an opportunity. In order to make the rigid and monotonous static web page "flexible", the industry urgently needs a software technology to develop a program that can spread through the network and run across platforms. Therefore, major IT companies in the world have invested a lot of manpower, material resources and financial resources. At this time, Sun Company remembered the oak tree that had been put on hold for a long time and re-examined the experimental platform written by software. Because it is written according to the hardware platform architecture of embedded system, it is very small, especially suitable for transmission systems on the network. Oak is also a simplified language, the program is very small, suitable for transmission on the network. Sun Company first introduced an applet that can be embedded in a web page and transmitted on the network together with a web Applet (applet is a technology that embeds small programs in a web page and executes it), and renamed Oak as Java (when applying for a registered trademark, it was found that Oak had been used, and a series of names were thought of, and finally a Java word was used, which was inadvertently mentioned by the proponent when drinking a cup of Java coffee). On May 23rd, Sun Company officially released Java and HotJava browsers at the Sun world Conference. IBM, Apple, DEC, Adobe, HP, Oracle, Netscape, Microsoft and other major companies have stopped related development projects, purchased Java licenses and developed corresponding Java platforms for their products. [5] [6]

1996 1.0, Sun Company released the first Java development toolkit (JDK 1.0), which is an important milestone in the development of Java and marks that Java has become an independent development tool. In September, about 83,000 web pages were made with Java technology. In June 5438+10, Sun Company released the first JIT compiler for Java platform.

1997 February, JDK 1. 1 came out, and in the following three weeks, it reached 220,000 downloads. On April 2nd, the Java One conference was held, and the number of participants exceeded 1 10,000, setting a record for similar conferences in the world at that time. In September, there were more than 654.38 million members of the Java developer connection community.

1998 12.8, released by the second generation Java platform J2EE Enterprise Edition. 1June, 1999, Sun Company released three versions of the second-generation Java platform (Java 2 for short): J2ME (Java 2 Micro Edition), which is used in mobile, wireless and resource-limited environments; J2SE(Java 2 Standard Edition, the standard version of Java 2 platform), applied to the desktop environment; J2EE(Java 2Enterprise Edition, Enterprise Edition of Java 2 platform) is applied to Java-based application servers. The release of Java 2 platform is the most important milestone in the development of Java, marking the beginning of the popularization of Java applications.

On April 27th, 1999, the hot virtual machine was released. HotSpot virtual machine was provided as a plug-in for JDK 1.2 when it was released, and later became the default virtual machine for all versions of Sun JDK after JDK 1.3 [7].

In May 2000, JDK 1.3, JDK 1.4 and J2SE 1.3 were released one after another. A few weeks later, they were supported by Apple's Mac OS X industry standard. On September 24th, 20001year, J2EE 1.3 released. On February 26th, 2002, J2SE 1.4 was released. Since then, the computing power of Java has been greatly improved. Compared with J2SE 1.3, there are nearly 62% more classes and interfaces. Among these new features, it also provides extensive XML support, secure socket support (through SSL and TLS protocols), brand-new I/OAPI, regular expressions, logs and assertions. On September 30th, 2004, J2SE 1.5 was released, which became another milestone in the development history of Java language. In order to show the importance of this version, J2SE 1.5 was renamed as Java SE 5.0 (build number 1.5.0) and code-named "Tiger". Tiger contains the most significant update since the release of 1996 version 1.0, including generic support, automatic packaging and improvement of basic types.

One of the founders of Java: james gosling

In June 2005, at the Java One conference, Sun released Java SE 6. At this time, various versions of Java have been renamed, and the number 2 has been removed. For example, J2EE is renamed JavaEE, J2SE is renamed JavaSE, and J2ME is renamed JavaME. [8]

On June 3rd, 2006, Sun Company, the inventor of Java technology, announced that Java technology would be released as free software. Sun officially released the first batch of source code about the standard version of Java platform and the executable source code of Java mini version. Since March 2007, all developers in the world can modify the Java source code [9].

In 2009, Oracle Bone Inscriptions Company announced the acquisition of Sun [10]. James gosling, one of the co-founders of 2065 438+00 Java programming language, resigned from Oracle Bone Inscriptions. On 20 1 1 year, Oracle Bone Inscriptions Company held a global event to celebrate the launch of Java7, and then Java7 was officially released. In 20 14, Oracle Bone Inscriptions released the official version of Java8 [1 1].

Programming development

Programming environment

Java concept map

JDK(Java Development Kit), also known as Java development kit or Java development tool, is a program development environment for writing Java Applet and applications. JDK is the core of Java, including Java runtime environment, some Java tools and Java API. Whatever the Java application server is, it has a built-in JDK version. The mainstream JDK is released by Sun Company. Besides Sun, many companies and organizations have developed their own JDK, such as Jrocket developed by IBM, JRocket developed by BEA and JDK developed by GNU organization [13].

In addition, the Java SE API subset and the Java virtual machines in the Java API class library can be collectively referred to as JRE(JAVA Runtime Environment), and JRE is a standard environment that supports the running of Java programs [14].

JRE is a running environment and JDK is a development environment. So you need JDK when writing Java programs and JRE when running Java programs. JDK already contains JRE, so as long as JDK is installed, you can edit and run Java programs normally. However, because JDK contains a lot of content unrelated to running and takes up a lot of space, it is not necessary to install JDK to run ordinary Java programs, but only JRE [15].

Programming tool

Eclipse: Java-based open source extensible development platform [16].

NetBeans: An open source Java integrated development environment suitable for various clients and Web applications.

IntelliJ IDEA: It has good automatic code prompting and code analysis functions. [ 17]

MyEclipse: commercial software developed by Genuitec, which is a widely used Java application integrated development environment [18].

EditPlus: If the Java compiler "Javac" and interpreter "Java" are configured correctly, you can directly use EditPlus to compile and execute Java programs [19].

language feature

1. Simple

Java looks a lot like C++, but in order to make the language small and familiar, designers have removed many available features in C++ language, which are rarely used by ordinary programmers. For example, Java does not support go to statements, but provides break and continue statements and exception handling. Java also eliminates the operator overloading and multiple inheritance characteristics of C++, and does not use the main file, thus eliminating the preprocessor. Because Java has no structure, arrays and strings are objects, so pointers are not needed. Java can automatically handle object references and indirect references, and realize the automatic collection of useless units, so that users don't have to worry about storage management and can spend more time and energy on research and development.

2. Object-oriented

Java is an object-oriented language. For programmers, this means focusing on data and the methods of manipulating data, rather than thinking strictly according to the process. In an object-oriented system, a class is a collection of data and methods for manipulating data. Data and methods together describe the state and behavior of an object. Every object is an encapsulation of its state and behavior. Classes are arranged according to a certain system and hierarchy, so that subclasses can inherit the behavior of superclasses. There is a root class in this class hierarchy, which is a class with general behavior. Java programs are organized by classes.

Java also includes a set of extended classes, which form various packages that users can use in their own programs. For example, Java provides a class (java.awt package) for generating graphic user interface module, where awt is the abbreviation of abstract windowing toolkit, a class for processing input and output (java.io package) and a class for supporting network functions (java.awt package).

Step 3 distribute

Java is designed to support network applications. It is a distributed language. Java not only supports various levels of network connections, but also supports reliable streaming network connections with Socket classes, so users can generate distributed clients and servers.

Network becomes the distributed carrier of software applications. Java programs can be run anywhere as long as they are written once.

4. Compilation and interpretation

The Java compiler generates bytecode instead of the usual machine code. Java bytecode provides an architecture-independent object file format, which is designed to effectively transfer programs to multiple platforms. Java programs can run on any system that implements Java interpreters and runtime systems.

In the explanatory environment, the standard "link" stage of program development has disappeared greatly. If Java still has a link stage, it is only a process of putting new classes into the environment, and it is an incremental and lightweight process. Therefore, Java supports rapid prototyping and simple testing, which will lead to rapid program development. This is a subtle development process, which is in sharp contrast to the traditional time-consuming "compile, link and test".

5. Robustness

Java was originally used as a language to write consumer electronics software, so it was designed to write highly reliable and robust software. Java eliminates some programming errors and makes it very easy to write reliable software with it.

Java language (a computer language, especially for creating websites)

Java is a strongly typed language, which allows the function of checking potential type mismatch to be extended at compile time. Java requires explicit method declaration and does not support implicit declaration in C style. These strict requirements ensure that the compiler can catch call errors and thus produce more reliable programs.

One of the most important enhancements in reliability is the storage model of Java. Java does not support pointers, which eliminates the possibility of overwriting storage and damaging data. Similarly, Java's automatic garbage collection prevents storage leaks and other harmful errors related to dynamic storage allocation and release. The Java interpreter also performs many runtime checks, such as verifying that all array and string accesses are within bounds.

Exception handling is another feature in Java, which makes the program more robust. An exception is a signal that an exception similar to an error has occurred. Using try/catch/finally statement, programmers can find the error handling code, which simplifies the task of error handling and recovery.

6. Security

Java's storage allocation model is one of its main methods to defend against malicious code. Java has no pointers, so programmers can't get hidden internal information and fake pointers pointing to memory. More importantly, the Java compiler doesn't handle storage scheduling decisions, so programmers can't guess the actual storage scheduling of classes by looking at the declarations. The actual storage address of the reference in the compiled Java code is determined by the Java interpreter at runtime.

The Java operating system uses bytecode verification process to ensure that the code loaded on the network does not violate any Java language restrictions. This security mechanism includes how to load classes from the Internet. For example, loaded classes are placed in a separate namespace instead of local classes to prevent malicious applets from replacing standard Java classes with their own versions.

7. Lightweight

Java makes language declarations independent of implementation aspects. For example, Java clearly states the size of each basic data type and its operation behavior (these data types are described by Java syntax).

The Java environment itself can be ported to new hardware platforms and operating systems. The Java compiler is also written in Java, and the Java running system is written in ANSIC language.

8. High performance

Java is a language that compiles first and then interprets, so it is not as fast as a fully compiled language. However, in some cases, performance is very important. In order to support these situations, Java designers have made an "just-in-time" compiler, which can translate Java bytecode into machine code of a specific CPU (central processing unit) at runtime, that is, realize full compilation.

Java bytecode format design takes into account the needs of these "just-in-time" compilers, so the process of generating machine code is quite simple, and it can produce quite good code.

9. Multi-thread operation

Java is a multithreaded language, which supports multithreaded execution (also called lightweight process), can handle different tasks, and it is easy to design programs with clues. Java's lang package provides a Thread class, which supports methods of starting thread, running thread, stopping thread and checking thread status.

Java cue support also includes a set of synchronization primitives. These primitives are widely used synchronization schemes developed by C.A.R.Haore based on the style of supervisor and conditional variables. With the keyword synchronized, programmers can prove that some methods cannot run in a class at the same time. These methods are under the control of the monitoring program to ensure that the variables are kept in a consistent state.

10. Dynamic

Java language is designed to adapt to the ever-changing environment. It is a dynamic language. For example, classes in Java are loaded on demand, and some are even obtained through the network. [20]

principle of operation

It includes four aspects:

principle of operation

(1)Java programming language

(2)Java class file format

(3)Java virtual machine

(4)Java application programming interface [2 1]

When editing and running a Java program, these four aspects should be involved simultaneously. Use word editing software (such as Notepad, WordPad, UltraEdit, etc.). ) or integrated development environment (Eclipse, MyEclipse, etc. Define different classes in Java source files [22], access the resource system by calling the methods in the classes (these classes realize Java API), compile the source files into binary intermediate codes and store them in the class files. Then run the class file by running the Java virtual machine corresponding to the operating system platform environment, execute the bytecode generated by compilation, and call the methods implemented in the class file to meet the Java API call of the program [6].

Language foundation

Basic data structure

There are eight data types in Java to store numeric values, characters and Boolean values.

Integer type

Integer types are used to store integer values, that is, values without decimal parts. It can be positive or negative. There are three representations of integer data in Java programs, namely decimal, octal and hexadecimal.

Integer data can be divided into four types according to the size of its content.

Data type memory

byte

8-bit

short

16 bit

Internationalorganizations (same as international organizations)

32-bit

Spread out completely

Floating point type

Data type memory

flotage

32-bit

double;twofold

64 bit

character type

The character type is used to store a single character and takes up 16 bits (two bytes) of memory space. When defining character variables, you should use single quotation marks. Use char keyword to define character variables.

Data type memory

tea

16 bit

boolean type

Boolean type is also called logical type. Boolean variables are defined by the keyword Boolean, and there are only two values, true and false, which respectively represent "true" and "false" in Boolean logic. Boolean type is usually used as a judgment condition in process control.

key word

Keyword meaning

abstract

Abstract class or method

maintain

Used to find internal program errors.

break

Jump out of a switch or loop

Spread out completely

Keywords reference data source [23]

operational character

Operators are some special symbols, which are mainly used in mathematical functions, certain types of assignment statements and logical comparisons.

assigning operator

The assignment operator is represented by the symbol "=". It is a binary operator (handling two operands), and its function is to assign the value contained in the right operand to the left operand.

For example:

int a = 100;

arithmetic operator

Operator description

+

increase

-

negative

*

Diverse

Spread out completely

Self-increasing and self-decreasing operator

Self-increasing and self-decreasing are monocular operators, which can be placed before or after operands. Operands must be integers or floating-point variables. The increasing and decreasing operator is used to increase or decrease the value of a variable by 1. The self-increasing and self-decreasing operator placed in front of the operand will first add 1 or subtract 1 to the value of the variable, and then let the variable participate in the operation of the expression. The self-increasing and self-decreasing operator placed after the operand will first make the variable participate in the operation of the expression, and then add 1 or subtract 1 to the variable value.

For example:

Suppose a=5.

b = ++ a; //First add 1 to the value of A, and then assign it to B. At this time, the value of A is 6, and the value of B is 6.

b = a++; //Assign the value of A to B first, and then change the value of A to 6. At this time, the value of a is 6 and the value of b is 5.

comparison operator

Comparison operators belong to binary operators and are used to compare variables, variables, independent variables and other types of information in programs. The result of the comparison operator is Boolean. When the relationship corresponding to the operator is established, the operation result is true, otherwise it is false. There are six * * * comparison operators, which are usually used as the basis of judgment in conditional statements.

Operator description

& gt

Compare whether the left is greater than the right.

& lt

Compare whether the left is less than the right.

==

Compare whether the left and right are equal.

Spread out completely

Logical operator

Operator operation

& amp& amp

Logic and

||

Logical or

!

Logical non

Basic language reference sources [24]

Program example

/* A simple Java application, which shows: Hello World!

The file name is hello.java */

Hello {

//The program starts from main ()

Public static void main (strinargs []) {

System.out.println("Hello World!" );

}

}

As the comment says, the main method is the first line of the program. For a Java application, the main method is essential, and the Java interpreter executes the program with main as the entrance, without generating any objects. Multiple methods can be defined in each class, but there can only be one main method. The keyword public indicates access rights, which means that all classes can use this method. In this case, main must be defined as public, because when the program starts to execute, it needs to be called by code other than its class. The keyword static indicates that the method is a class method. The keyword void indicates that the main () method does not return a value. The string args[] defined in parentheses of the main method is a parameter passed to the main method. The parameter named args is an object of class String. The parameters of the method are specified by "class name parameter name", and multiple parameters are separated by commas. The last character of this line is "{",indicating the beginning of the main program body, and all the codes contained in a method will be enclosed in curly braces. In addition, main is just where the interpreter starts to work. A complex program may contain dozens of classes, but these classes only need one main method. [25]

language standard

1997165438+1October 17 The International Organization for Standardization (ISO) agreed to adopt Sun's patented technology-Java as the ISO standard. As a technical standard, JAVA is free to the public. With the approval of ISO, Sun will be able to submit the standardized platform specification of JAVA. [26]

Release time name

2000 10 65438

ISO/TS 10303-27:2000

May 2006

ISO/IEC 19777-2:2006

20 14 July 15

ISO/IEC TR 13066-6:20 14

Spread out completely

Language standard reference [27] [28] [29] [30] [3 1]

Language specification

JCP(Java Community Process) is an open international organization, which is mainly composed of Java developers and licensees. Its function is to develop and update Java technical specifications, reference implementation (RI) and technical compatibility package (TCK).

The specifications maintained by JCP include Java ME, Java SE, Java EE, XML, OSS, JAIN, etc. Members of an organization can submit JSR(Java specification request) and enter the next version of the specification after passing a specific program.

JSR is a concrete description of the Java platform specification that was put forward early and finally released. Usually, a new JSR is proposed to increase or standardize the functions of the Java platform. The specific JSR is formulated by the expert group, and the work is coordinated by the team leader. For example, CLDC 1.0 (JSR30) is led by Antero Taivalsaari of Sun Company, and the members of the expert group include Siemens, Motorola, Nokia and Symbian. The Java ME platform specification is defined in JSR68, and the leader of the specification is Jon Courtney of Sun Company.

After JSR is completed, relevant specifications and JavaAPI will be published on the official website of JCP. Equipment manufacturers can implement JSR in their own products, such as MIDP2.0(JSRll8). But these must pass the TCK (Technical Compatibility Kit) test to ensure technical compatibility. [32]

According to the technical category, it can be divided into the following categories:

1, J2EE platform specification [33]

2, J2SE platform specification [34]

3, J2ME platform specification [35]

4, operation support system specification (OSS)[36]

5, integrated network Java application (JAIN)[37]

6, XML operation specification [38]

technology application

1, Android application

Many Android applications are developed by Java programmers and developers. Although Android uses different JVMs and different encapsulation methods, the code is still written in Java language. A considerable number of mobile phones support JAVA games, which makes many non-programmers understand JAVA.

2. Server programs applied to the financial industry

Java is widely used in financial services, and many third-party trading systems, banks and financial institutions choose to develop with Java because it is relatively safe [39]. Large multinational investment banks use Java to write foreground and background electronic trading systems, settlement and confirmation systems, data processing projects and other projects. In most cases, Java is used for server-side development, but most of them have no front end. They usually receive data from one server (upper layer), process it and send it to another processing system (lower layer).

3. Website (the host station of the World Wide Web)

Java occupies a certain position in the field of e-commerce and website development. Developers can use many different frameworks to create web projects, such as SpringMVC, Struts2.0 and frameworks. Even simple servlet, JSPs and struts-based websites are often used in government projects. For example, the websites of different departments such as medical care, insurance, education and national defense are all developed based on Java.

4. Embedding fields

Java has a great development space in the embedded field. On this platform, you only need 130KB to use Java technology (on smart cards or sensors).

5. Big data technology

Many big data processing technologies, such as Hadoop, are Java-based, such as Apache's Java-based HBase and Accumulo, and ElasticSearchas.

6. Space for high-frequency trading

Java platform improves the characteristics of this platform, even if compiled, it can transmit data like C++. It is for this reason that Java has become the language for programmers to write trading platforms, because although its performance is not as good as C++, developers can avoid problems such as security, portability and maintainability.

7. Scientific application

Java is a good choice in scientific applications including natural language processing. The main reason is that Java is superior to C++ or other languages in security, portability, maintainability and concurrency of other high-level languages.

Java language is easy to learn and difficult to master, and configuring things is more complicated.