Notes 20180506 : Overview of the Java programming language

2. Overview of Java programming language  

  If you pay attention to the list of development languages, you will find that Java has been the top advanced development language for a long time. As a Java developer, I am proud of this and also deeply worried. It’s because the development language I’ve come into contact with is so powerful, and I’m worried that if Java’s market share is no longer there, where will we go? A kind of worry about open source)? However, these are all unfounded worries for me as a small programmer. Before Java declines, we should understand Java first, and then have a deep understanding of the computer world. For the Java programming language , We mainly learn from several aspects: the history of the language, the basic composition of the language, object-oriented, strings and numbers, common tool classes, collections, IO, multi-threading, etc.

  Today's study is mainly to introduce an overview of the Java programming language, and the content explains how Java came into being and what advantages it has. Let's start today's study;

foreword

  Java is an object-oriented programming language, which is derived from the C++ language. It not only absorbs various advantages of the C++ language, but also abandons the concepts of multiple inheritance and pointers that are difficult to understand in C++. Therefore, the Java language has powerful functions and is simple and easy to use. Use two features. As a representative of static object-oriented programming language, Java language perfectly implements object-oriented theory, allowing programmers to perform complex programming in an elegant way of thinking.

  Java has the characteristics of simplicity, object orientation, distribution, robustness, security, platform independence and portability, multithreading, and dynamism. Java can write desktop applications, web applications, distributed systems and embedded system applications.

  The above is Baidu Encyclopedia's explanation of Java. People with development experience can understand it very well, but for some programs that are first involved in development, they may not be able to understand the meaning behind each word. Let's start from Java. talk about;

2.1 Introduction to Java

  Java is a high-level object-oriented programming language. Programs written in the Java language are cross-platform. From PCs to handheld computers, there are programs and games developed in Java. Java programs can run on any computer, operating system, and hardware devices that support Java.

2.1.1 History of the Java Language

  In the 1990s, the single-chip computer 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 consumption of consumer electronic products ( such as TV set-top boxes, TV set-top boxes, etc.). How smart is the bread oven, mobile phone, etc. ) . In order to seize the market opportunity, Sun established a project group called Green in 1991. Patrick, James Gosling, Mike Sherindan and several other engineers worked together in the sand dunes of Menlo Park, California. In a small studio of Lu, he researches and develops new technologies, specializing in the embedded application of computers in home appliances.

  Because of the advantages of C++, the researchers of this project group first considered using C++ to write programs. But for monolithic systems with extremely scarce hardware resources, C++ programs are too complicated and huge. In addition, due to the variety of embedded processor chips used in consumer electronic products, it is also a difficult problem how to make the written programs run across platforms. In order to solve the difficulties, they first focused on the development of the language, assuming a hardware platform architecture with a simple structure that meets the needs of embedded applications, and formulated corresponding specifications for it, which defined the binary machine code of this hardware platform. The instruction system (that is, the instruction system that later became "bytecode"), after the language is successfully developed, semiconductor chip manufacturers can develop and produce this hardware platform (this is actually the origin of Java's cross-platform design) . For the design of the new language, Sun's R&D personnel did not develop a brand-new language, but modified C++ according to the requirements of embedded software, and removed some unpractical and safety-impacting components left in C++. Combined with the real-time requirements of embedded systems, an object-oriented language called Oak is developed. (OaK is the predecessor of the Java language), the name comes from an oak tree (OaK) outside the window of James Gosling's office.

  Since there is no hardware platform for running bytecodes when developing the Oak language, in order to conduct experimental research on this language during development, they based on the existing hardware and software platforms, according to their own designation. Specification, using software to build a running platform (this is actually the essential concept of JVM, it is just a virtual realization of the hardware environment where software runs) , the whole system is simpler than C++, there is no big difference. In the summer of 1992, when the Oak language was successfully developed, researchers demonstrated the Green operating system, Oak's programming language, class libraries and its hardware to hardware manufacturers to convince them to use Oak language to produce hardware chips, but, Hardware makers haven't been very enthusiastic about it. Because they believed that the risk of producing hardware products when everyone knew nothing about the Oak language was too risky, so the Oak language could not enter the market because of the lack of hardware support, so it was shelved. .
  In June and July 1994, after a three-day discussion, the team decided to change the goals of the effort again, this time by applying the technology to the World Wide Web. They believe that with the arrival of the Mosaic browser, the Internet is evolving towards the same hyper-interactive vision that they saw in cable networks. As a prototype, Patrick Norton wrote WebRunner, a small web browser.
  In 1995, the boom of the Internet gave Oak an opportunity. In order to make rigid and monotonous static web pages "flexible", the industry urgently needs a software technology to develop a program that can be spread through the network and can run across platforms . As a result, the world's major IT companies have invested a lot of human, material and financial resources for this. At this time, Sun remembered the Oak that had been put on hold for a long time, and re-examined the test platform written in software. Because it was written in accordance with the hardware platform architecture of embedded systems, it was very small, especially suitable for network The transmission system on the Internet, and Oak is also a streamlined language, the program is very small, suitable for transmission over the network. Sun company first introduced Applet (Applet is a technology that embeds small programs into web pages for execution) that can be embedded in web pages and can be transmitted on the network along with web pages, and changed Oak's name to Java (when applying for registered trademarks, it was found that Oak has already been used, and after thinking of a series of names, finally, the Java word that the proposer had inadvertently mentioned over a cup of Java coffee) was used . On May 23, Sun officially released Java and HotJava browsers at the Sun world conference. Major companies such as IBM, Apple, DEC, Adobe, HP, Oracle, Netscape and Microsoft have all stopped their related development projects, competed to buy Java licenses, and developed corresponding Java platforms for their products.
  In January 1996, Sun released the first development kit for Java (JDK 1.0) , which was an important milestone in the development of Java, marking that Java became an independent development tool. In September, about 83,000 web pages were created using Java technology. In October, Sun Corporation released the first just-in -time (JIT) compiler for the Java platform .
  In February 1997, JDK 1.1 was released, and in the following three weeks, it reached 220,000 downloads. On April 2, the Java One conference was held, with more than 10,000 participants, setting a record for the scale of similar conferences in the world at that time. In September, the Java Developer Connection community exceeded 100,000 members.
  On December 8, 1998, J2EE, the enterprise version of the second-generation Java platform, was released. In June 1999, Sun released three versions of the second-generation Java platform (referred to as Java2): J2ME (Java2 Micro Edition, a micro version of the Java2 platform), which is used in mobile, wireless and limited resource environments; J2SE ( Java 2 Standard Edition, the standard edition of the Java 2 platform), applied to the desktop environment; J2EE (Java 2 Enterprise Edition, the enterprise edition of the Java 2 platform), applied to Java-based application servers. The release of the Java 2 platform is the most important milestone in the development of Java, marking the beginning of the popularization of Java applications. (The 2 of J2EE, etc. that we have seen in books or other subclasses in the past comes from Java 1.2 version)
  On April 27, 1999, the HotSpot virtual machine was released. The HotSpot virtual machine was released as an add-on to JDK 1.2, and it has since become the default virtual machine for JDK 1.3 and all later versions of the Sun JDK.
  In May 2000, JDK1.3, JDK1.4 and J2SE1.3 were released one after another, and a few weeks later it was supported by the industry standard of Apple's Mac OS X. On September 24, 2001, J2EE1.3 was released. On February 26, 2002, J2SE1.4 was released. Since then, the computing power of Java has been greatly improved. Compared with J2SE1.3, it has nearly 62% more classes and interfaces. Among these new features are extensive XML support, secure sockets (Socket) support (via SSL and TLS protocols) , a new I/O API, regular expressions, logging and assertions. On September 30, 2004, J2SE1.5 was released, which became another milestone in the history of Java language development. To express the importance of this release, J2SE 1.5 was renamed Java SE 5.0 (build number 1.5.0) , codenamed "Tiger", and Tiger included the most significant update since version 1.0 was released in 1996, including generics Support, autoboxing of primitive types, improved looping, enumeration types, formatted I/O, and variadic arguments.
  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 cancelled. For example, J2EE was renamed JavaEE, J2SE was renamed JavaSE, and J2ME was renamed JavaME.
  On November 13, 2006, Sun, the inventor of Java technology, announced that it would release Java technology as free software. Sun officially released the first source code for the Standard Edition of the Java Platform, as well as the executable source code for the Java Mini Edition. From March 2007, all developers around the world can make changes to the Java source code.
  In 2009, Oracle Corporation announced the acquisition of Sun. In 2010, James Gosling, one of the co-founders of the Java programming language, resigned from Oracle. In 2011, Oracle held a global event to celebrate the launch of Java 7, which was then officially released. In 2014, Oracle released the official version of Java 8.

1.1.2 What is the Java language

  Java is a highly creative object-oriented programming language launched by Sun in 1995. It was designed by Dr. James Gosling, an academician of Sun Research Institute, known as the father of Java. And completed the original compiler and virtual machine of Java technology. Java's original name was OAK, which was renamed Java in 1995 and officially released.

  Java is an interpreted language , and its syntax rules are similar to C++. At the same time, Java is also a cross-platform programming language. Programs written in the Java language can run on any platform and device, such as IBM personal computers, MAC Apple computers, various microprocessor hardware platforms, as well as Windows, UNIX, OS/2, MAC OS and other system platforms. Implement " write once, run anywhere ". Java is very suitable for enterprise network and Internet environment, and has become one of the most influential and popular programming languages ​​on the Internet.

  Compared with the currently commonly used C++, the Java language is much more concise, and it has improved reliability, removed the biggest source of program errors, and has high security. It can be said that it is the most excellent programming language in history.

  Programs written in the Java language are both compiled and interpreted . The program Compilation happens only once, while interpretation happens every time the program is run. The compiled bytecode is saved in a form of machine code optimized for the JVM. The virtual machine interprets the bytecode into machine code and then runs it on the computer. The compiling and running process of Java language program code is shown in Figure 1.1.

 

                              Figure 1.1 Compile and run process of Java program

1.1.3 Application areas of Java

  With Java, program developers can freely use existing hardware and software system platforms. This is because Java is platform-independent, and it can also be used in areas other than computers. Java programs can run on portable computers, televisions, telephones, mobile phones, and a large number of other electronic devices. There are countless uses for Java, its unparalleled capabilities, and its considerable time and cost savings. The main application areas of Java are as follows:

  • Desktop application system development.
  • Embedded system development.
  • e-commerce application.
  • Enterprise application development.
  • Interactive system development.
  • Development of multimedia systems.
  • Distributed system development.
  • Web application system development.

  Java is ubiquitous, has millions of users, and is growing faster than any computer language before it. Java can bring countless benefits to businesses and end users. Oracle Chairman and CEO Larru Ellison said: "Java is entering businesses, homes, and schools. It is becoming as ubiquitous as the Internet itself."

  If you look closely, you will find that Java is all around us, such as the Java development tools we often use, Eclipse, NetBeans, JBuilder, etc., and excellent software such as RSSOwl, Limewire, Azureus, CyberDuck, and OpenOffice are all written in Java. In addition, various mobile phone manufacturers have provided Java technology support for their products, and there are countless Java programs and games on various mobile phones.

1.1.4 Java version

  Since Sun introduced Java, it has tried to make it omnipotent. Java has been developed so far and is divided into three versions according to the scope of application, namely Java SE, Java EE, Java ME, which is the Java ONE (Open Net Environment) system. This section will introduce the three Java versions separately.

1.Java SE

  Java SE is the standard version of Java, which is mainly used for the development of desktop applications and the foundation of Java. It includes Java language foundation, JDBC (Java database connectivity operation), I/O (input and output), network communication, multiple technology such as threading. The structure of Java SE is shown in Figure 1.2.

 

Figure 1.2 The structure of Java SE

2.Java EE

  Java EE is the enterprise version of Java, which is mainly used to develop enterprise-level distributed network programs, such as e-commerce websites and ERP (Enterprise Resource Planning) systems. Its core is EJB (Enterprise Java Component Model). The structure of Java EE is shown in Figure 1.3.

       

Figure 1.3 The structure of Java EE

3.Java ME

  Java ME is mainly used in the development of embedded systems, such as handheld computers, mobile phones and other mobile communication electronic devices. Now most mobile phones produced by mobile phone manufacturers support Java technology. The structure diagram of Java ME is shown in Figure 1.4.

Figure 1.4 Structure of Java ME

1.1.5 How to learn Java well

  How to learn the Java language well is a common problem that all beginners need to face. In fact, the learning methods of each language are similar. The main points that beginners need to pay attention to are the following:

  • Determine your own learning goals and general direction, choose and lock in a language, study hard according to your own learning direction, and study carefully.
  • Beginners should not read too many books, first find a relatively basic book for systematic study. Many program developers have worked for a long time and are only familiar with some of the basics, and have not systematically learned the Java language.
  • Learn about design patterns. Development programs must write program code, which must be highly readable, so that the programs written can be debugged, maintained, and upgraded. Learning some design patterns can better grasp the overall structure of the project.
  • Don't memorize grammar. When you are new to a language, especially the Java language, you can master the basic syntax and understand some functions. With the help of the code assist function of development tools (such as Eclipse or NetBeans), complete the entry of the code, so that you can quickly enter the learning state.
  • Practice more, think more, and ask more. It is not enough to only understand the content and technology in the book. You must write the program code, run the program, and analyze the operation structure, so as to have an overall understanding and affirmation of the learning content. Think your own way, write code to improve your programming thinking. I usually ask teachers or managers for more advice, communicate more technical issues with others, and improve my skills and knowledge.
  • Don't be impatient. When encountering technical problems, you must deal with them calmly, do not let your thinking be confused, and keep a clear head in order to analyze and solve various problems. Try relaxing yourself with songs and walking.
  • If you encounter a problem, first try to solve it yourself, so that you can improve your program debugging ability, have a certain understanding of common problems, understand the cause of the error, and even draw inferences from one case to solve other related errors.
  • Read more information. You can often go to the Internet to search for relevant information or methods to solve problems. The Internet has excerpted the problems encountered by many people and different solutions. Analyze these methods to solve problems and find the most suitable method for you.
  • Read other people's source code. Not only to understand other people's program code, but also to analyze the programmer's programming ideas and design patterns, and integrate them for their own use.

1.1.6 Java API Documentation

  The full name of API is Application Programming Interface, that is, application programming interface. The Java API document is an indispensable programming dictionary for Java program development, and records a large number of APIs in the Java language, mainly including the inheritance structure of classes, member variables and member methods, construction methods, and detailed descriptions and descriptions of static members. You can find the latest version of the JDK documentation (that is, the API documentation) on the Java website http://java.sun.com. The page effect of the Java API documentation is shown in Figure 1.5.

Figure 1.5 Java API Documentation Page

1.1.7 Java Language Composition

Java consists of four aspects:

● Java programming language, that is, syntax.

●Java file format, that is, the suffix of various folders and files.

● Java Virtual Machine (JVM), the interpreter that processes *.class files.

- Java Application Programming Interface (Java API).

1.2 Features of the Java language

  The authors of the Java language have written a widely influential Java white paper, which describes their design goals and implementation results in detail, and briefly introduces the features of the Java language. These features are briefly described below.

1.2.0 Simple

  The syntax of the Java language is simple and clear, easy to master, and is a pure object-oriented language. The simplicity of the Java language is mainly reflected in the following aspects:

  • The syntax rules are similar to C++. In a sense, the Java language is evolved from the C and C++ languages, so C programmers can easily grasp the syntax of the Java language.
  • The Java language simplifies and improves C++. For example, Java uses interfaces instead of multiple inheritance and does away with pointers because pointers and multiple inheritance often complicate programs. The Java language also greatly simplifies the resource release management work of programmers by implementing automatic garbage collection.
  • Java provides a wealth of class libraries and API documents and third-party development kits. In addition, there are a large number of Java-based open source projects. The JDK (Java Developer Toolkit) has open source code. Readers can analyze the source code of the project, thus Improve your programming skills.

1.2.1 Object-Oriented

  Object-oriented is the foundation of the Java language and an important feature of the Java language. It is a pure object-oriented programming language. Java advocates that everything is an object, and the syntax cannot define separate data and functions outside the class. That is to say, the outermost data type of the Java language is an object, and all elements must be accessed through classes and objects.

  Object-oriented can also be understood by comparison with process-oriented: object-oriented is relative to process-oriented, process-oriented focuses on the realization process of functions, while object-oriented encapsulates the implementation of the same function into an object, and then calls this Objects to focus on functionality, focus on objects that can implement functionality.

1.2.2 Distribution

  The distribution of Java includes operation distribution and data distribution. Operation distribution refers to arranging related operations on multiple different hosts, while data distribution refers to storing data on multiple different hosts. These hosts are different in the network. member. Java can access network objects by means of URL (Uniform Resource Locator) objects in the same way as accessing the local system.

1.2.3 Portability

  Java programs have the characteristics of being independent of the architecture and can be easily transplanted to different computers on the network. At the same time, the Java class library also implements interfaces for different platforms, so that these class libraries can be ported.

1.2.4 Interpreted

  An interpreter is required to run a Java program. Any computer or other device that has a Java interpreter ported can interpret and execute Java bytecodes. Bytecode is platform independent, and it carries a lot of compile-time information, making the linking process easier, the development process faster, and more exploratory.

1.2.5 Security

  The Java language deletes syntaxes such as pointers and memory release in the C language, effectively avoiding illegal memory operations. The Java program code can only run after many test steps such as code verification and pointer verification, so it is impossible for the Java program without permission to damage the system platform, and Java can be used to write anti-virus and anti-modification systems.

1.2.6 Robustness

  One of the design goals of Java programs is to write multi-faceted, reliable applications. Java will check for errors at compile and runtime, and eliminate errors. Type checking can help users detect many errors that occur early in development. The advent of integrated development tools (eg Eclipse, NetBeans) has also made it easier to compile and run Java programs.

1.2.7 Multithreading

  The multi-threading mechanism enables the application to execute multiple tasks in parallel at the same time, and the corresponding synchronization mechanism can ensure that different threads can correctly share data. Using multithreading can bring better interactivity and real-time behavior.

1.2.8 High Performance

  The compiled bytecode of Java is run in the interpreter, so its speed is more interactive [interactive means that you talk to the program. For example, you click a button, and the program pops up a window "You really want to quit "So you can choose. This is called interaction. Most of the current programs are interactive programs. ] The application has improved a lot. In addition, the bytecode can be translated into platform-specific machine instructions when the program is running, thereby further improving the running speed.

1.2.9 Dynamic

  Java is in many ways more adaptable to the development environment than C and C++, and can dynamically adjust library methods and add variables without requiring any changes on the client side. Dynamic adjustment in Java is very simple and straightforward.

1.2.10 Architecture Neutral

  Programs written in Java are compiled to generate bytecode. Not only can this bytecode be easily executed on any machine, but it can also be dynamically translated to native machine code. This is a manifestation of Java's architecture neutrality, but it is still JVM-dependent.

Summarize

  Thanks to Java's cross-platform and rich toolkit support, Java has become an important development language in today's Internet age; although computer technology is advancing day by day, it is still wise to choose Java.

Deep Dive: Java Cross-Platform

  Every time I talk about the cross-platform of Java, there is a lot of meaning. This is why I spend a lot of time on the history of Java in this chapter. It has been discussed in , and if you want to know more, you can refer to In-depth Java Cross-Platform.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325301320&siteId=291194637