Java in the past and present lives

Java was originally a programming language developed by James Gosling (Godling, known as the father of Java) of Sun (now acquired by Oracle) in the early 1990s. Originally named Oak, it was aimed at embedded applications for small appliance devices, but the market did not get much response. However, the rise of the Internet brought Oak back to life, so Sun reinvented Oak and released it as Java in 1995, because Oak had already been registered, so Sun registered the Java trademark. With the rapid development of the Internet, JAVA has gradually become the most important network programming language.

Java is somewhere between a compiled and interpreted language. In order to ensure that different platforms, different companies developed virtual machines can correctly execute Java bytecode, Sun developed a series of Java virtual machine specifications. From a practical point of view, JVM compatibility is very good, and a low version of Java bytecode can run perfectly well on a high version of the JVM.

As Java evolved, Sun divided Java into three different versions:

  • Java SE: Standard Edition
  • Java EE: Enterprise Edition
  • Java ME: Micro Edition

What is the relationship between these three?

In short, Java SE is the standard edition, including the standard JVM and standard libraries, while Java EE is the enterprise edition, which only adds a large number of APIs and libraries on the basis of Java SE to facilitate the development of Web applications, databases, messaging services, etc. Java EE applications use exactly the same virtual machine as Java SE.

Without a doubt, Java SE is the core of the entire Java platform, and Java EE is a must for further learning about Web applications. Familiar frameworks such as Spring are part of the Java EE open source ecosystem.

Noun explanation

  • JDK: Java Development Kit
  • JRE: Java Runtime Environment (Java Runtime Environment, which is mainly composed of a JVM running Java bytecode files, namely Java Virtual Machine)

The relationship between the two is as follows:

Simply put, a JRE is a virtual machine that runs Java bytecode. However, if you only have Java source code, you need the JDK to compile into Java bytecode, because the JDK includes a compiler, debugger, and other development tools in addition to the JRE.

Environment configuration

Learning any programming language, there are senior recommended IDE or official development tools, as well as the configuration of the running environment, this is a must. Idea 2021 and JDK8 are selected here.

JDK download and install

1, download

Website download link: https://www.oracle.com/java/technologies/javase-downloads.html

Xiaobian here to use the JDK8 version, is currently used more stable version, recommended to use. If they can’t download can visit here to extract ha: https://pan.baidu.com/s/1tb1AG-FBHpYRsw0Q5U9YLw extraction code: 3 KWK

2, installation,

Xiaobian to Win10 system as an example, download after decompression can be, Xiaobian is no need to install the version. Note on the path to unzip: do not use a path with Chinese characters. In addition, it is strongly recommended that your computer’s disk name and account name be changed to English, or pinyin, so that you can avoid some strange problems, although these problems may be installed later database or other software will appear, but the world of the program is not to recognize Chinese characters.

3. Configure the environment

Desktop This computer, according to the following operation order: right mouse button –> properties –> Advanced System Settings –> Advanced -> environment variables:

After selecting the environment variable, we can see the following interface, then select the system variable -> new, then a dialog box will pop up to create a new system variable, enter JAVA_HOME at the variable name, enter the installation path of JDK in the variable value, and click OK.

We also need to modify the system PATH variable. Add the following two paths after the variable:

%JAVA_HOME%\bin
%JAVA_HOME%\jre\bin

Create/modify the CLASSPATH variable

If the CLASSPATH variable exists, select it and click Edit. If not, click New.

Enter/Add after the existing variable value:

Variable name: CLASSPATH Variable value:..; %JAVA_HOME%\lib\dt.jar; %JAVA_HOME%\lib\tools.jar;

Verify that the installation was successful

To bring up the command line window, use the shortcut Win+R and type CMD

Enter Java, if you can appear similar to the following information, the configuration is successful.

Then enter the command javac, java-version command in turn, if there is no error information is OK, one of the latter command is to view your JDK version number, if a long time to forget which version of the JDK installed at that time, you can view through this command.

IDEA Download and install

Download address: https://www.jetbrains.com/idea/download/#section=windows

This is the 64-bit version of Ultimate. It can be downloaded in EXE or ZIP format, so you can try it by yourself.

Installation is simple, almost all the way to Next. It is recommended that we do not put the software are used to install in the C disk, so that the C disk will be bigger and bigger, and finally lead to the computer is stuck.

It is recommended that you modify the font size and display method divider in the edit area. The latter When you have a lot of methods, it’s not easy to tell the beginning of a method from the end of a method, especially when you have all the folding methods.

File– –>Settings, then change the Settings using the following image:

File– –>Settings, then change the Settings using the following image:

In addition to these two very basic Settings, the other according to personal preferences to adjust their use of the most comfortable can be.

Hello World,

Many authors on this part of the network are put it in the back, because things a little bit more involved, here refers to a noun, this for beginners, it’s difficult to understand, but small make up closely studied, at the very beginning there is no problem, always listen to good, at least in the mind have a low.

Write your first Java program

Create the first Java program: File–>New–>Project –>Next–>Next–>

Project name is the name of the Project we created. We can name it by ourselves.

Project location

Project location

Project location

Then finish, we should see the following screen:

To create the first Java program, right-click in SRC, and select New –>Java Class–> and enter the name of the Class you want to create (the naming rules for Class names will be discussed later in this article) –>.

For example, the class name I typed in here is mainHello:

public class MainHello {
    
}

This step is equivalent to creating a Java file, but there is no function entry executed by the system. For the moment, this entry can be understood as the entrance of a scene in real life (for example, ticket entrance of scenic spot), but there is only one entry of the Java file. Next, we will create this entry function:

To quickly generate this method, type main+ enter using the shortcut:

Modifying this shortcut is as simple as removing the default intelligent prompt limit (by default, only the uppercase first letter will prompt the full system class, keywords, etc.).

The generated method is as follows:

public class MainHello {

    public static void main(String[] args) {
        
    }
}

At this point, you will see the green run button, which is the default entrance of the system, and the rest of the learning will be carried out here. Xiaobian first here to use the output statement provided by the system, output we are familiar with the Hello World.

public class MainHello { public static void main(String[] args) { System.out.println("Hello World"); }}

Then click Run to see the results.

parsing

Here is a simple parsing of the entry point of a Java program, the main function. First look at the different colored rectangles in the image below

  • publicThis is called in Javaqualifier, and there are moreprivate,protectedanddefault(default is not to write this), the function of the class file or the class in the method access limit, can be seen from the following:

  • classIt’s in the Java languageThe keywordIn addition, there are many other keywords as wellReserved wordsThe latter is when the system is not used for the time being but is kept in place for possible future use, but not for developers. For example:goto. Understand the following:

  • MainHello is the identifier we define. In the Java language, identifiers are named regularly:

    • Be case-sensitive
    • You can’t start with a number
    • It can only be done by combining one or more letters, numbers, underscores, and $
    • You cannot occupy keywords and reserved words in Java
    • The name is known by the name
    • Nomenclature, hump naming is recommended (not required, recommended)

Identifiers for class names, method names, variables, and blocks of statements are the most commonly used.

  • main(String[] args)Is one of the forms of a function in Java: one that takes one argumentmethods. When I talk about functions and methods in Java, I really mean the same thing. There are two types of methods in Java based on the number of arguments:Parameterless methodandParameter methods (the number of parameters can be defined), where the type of the parameter can also be customized.

Here, the main method takes an argument of the type array of a string, and there is a new noun: array. In Java, arrays can be divided into one-dimensional arrays and multidimensional arrays, depending on their dimensions.

The understanding of an array can be simply understood as a box of billiard balls, each ball has a number is the characteristics of the array, which is called the index in the Java language, the index starts from 0, such as a total of 10 balls, then the index is 0~9.

Summary of the Java program entry involved in the relevant content is introduced here, the specific content will be explained in detail.

The data type

Data types in the Java language fall into two broad categories: basic data types and reference data types. This is clear from the map below:

Into the system

There are four ways to represent integers in Java: decimal (which is what we usually use), binary, octal, and hexadecimal.

  • Binary: Starting with 0B or 0B, including numbers from 0 to 1.
  • Decimal: Includes the numbers from 0 to 9.
  • Octal: starts with 0 and includes the numbers from 0 to 7.
  • Hexadecimal: Starting with 0x or 0x, including numbers from 0 to 9, and the letters A~F, A~F.

Hexadecimal conversion

Other base to decimal

Formula: the coefficient * the power of the cardinal number (the coefficient refers to each number, the cardinal number refers to how many base, the weight refers to the right to left from 0, the power is the power)

For example, evaluate the decimal value 0x100:

0x100 = 1*16^2 + 0 * 16^1 + 0 * 16^0

       =  16*16

       =  256

Decimal to other base

Formula: Divide the base (the cardinal number, which is the base system to be converted) and take the remainder (the remainder) backwards.

For example, calculate the binary of 60:

variable

  • It’s in memory
  • According to scope, it can be divided into local variables and global variables
  • Declaring rule: Variable type Variable name, such as int stuAge
  • Variable assignment: =
  • Rules for using variables: declare first, use later
  • Default value for variables: The default value for the base data type is. The default value for the reference type isnull, the Boolean default value isfalse.

A constant is actually a special case of a variable. Constants are final, and their values cannot be changed twice. They are usually defined in uppercase letters.

conclusion

Yesterday saw a video about programming fun, recommend you to look at the https://youtu.be/dU1xS07N-FA.

I believe that learning Java all know the saying: compile once, run anywhere. So what’s the principle behind it?

“The Java compiler does not compile all classes into a single machine code program. Instead, it compiles each class independently, not to machine code, but to special intermediate code (bytecode). When the program starts, this bytecode is compiled into machine code.”

This is why Java is widely used in many industries and is increasingly being used as one of the preferred languages for developers to learn.

Xiaobian specially created a public number:
Recommended to learn Java, will share with
javaRelated content, and based on the original, welcome to search attention (attention that is to send Xiaobian selected boutique video tutorials), learn Java together!