(B) java quick start

A, java Introduction

1, the installation JDK

Because Java programs must run on the JVM, so the first thing we do is install the JDK.

Oracle's official website

Now need to login to download, you can use the version provided below to download jdk8 (currently more applications are basically version 8)

Link: https: //pan.baidu.com/s/1CfhayA2iIaoZrE-OMEMOjw
extraction code: fdd9

Set the environment variable ( PS: the main attention here given jdk, jre path must not have Chinese, etc., it is best not to take the space character )

This can refer to Baidu search: installation and configuration environment variable jdk1.8

Here Insert Picture Description

After configuration, cmd type

java -version

The following message will appear, representing the successful installation of jdk operating environment.

Here Insert Picture Description

2, a java program

We have to write your first Java program.

Notepad open, enter the following code:

public class Test{
    public static void main(String[] args){
        System.out.println("Hello, world!");
    }
}

Save the file, edit file name Test.java, then win + R input cmd, dos open command interface, enter the command to run the following program:

Here Insert Picture Description

Here Insert Picture Description

How to run java program

Java source code is a text file in nature, we need to use javacthe Test.java 编译成字节码文件Test.class ,然后,用java` command executes this bytecode files:

┌──────────────────┐
│    Hello.java    │<─── source code
└──────────────────┘
          │ compile
          ▼
┌──────────────────┐
│   Hello.class    │<─── byte code
└──────────────────┘
          │ execute
          ▼
┌──────────────────┐
│    Run on JVM    │
└──────────────────┘

Therefore, the executable javaccompiler, and an executable file javais the virtual machine.

to sum up

This is mainly to let everyone run visual impression of the first program under the experience, know a basic java program is how to implement it;

A java source code can only define a public type of class, and the class name and the file name to be exactly the same;

Execution: javac source code is compiled into .class .java the byte code, java then run a program has been compiled java class name as a parameter;

3, use the IDE development tools

We must first of its profits. The advantage of using IDE that press can write code, organize projects, compiling, running and debugging environment into a run, can greatly improve development efficiency.

IDE to enhance development efficiency depends mainly on the following points:

  • Automatically prompts the editor, can greatly improve the speed of the code knock;
  • After the code is modified to automatically recompile and run directly;
  • Can easily breakpoints.

Here, I can only recommend the best tools: IntelliJ Idea, no one, attach a download link and basic tutorial (link: https: //pan.baidu.com/s/1aAmwDgN3XM1zg1h_lxSLiw extraction code: z3vx)

activate idea: to enter http://fls.jetbrains-agent.com under License server.
Here Insert Picture Description

The basic idea tool does not require any configuration, use the default base are met. Here mainly configured with a relatively large number of "case-insensitive code hints" function, as follows:

File-> settings-> Editor-> Code Completion, remove the top Match case check box, and other versions of some small differences, self-Baidu search.
Here Insert Picture Description

4, the first demonstration of using the IDE tools java program

File-> new Project-> Java, shown in FIG.

Here Insert Picture Description

Here Insert Picture Description

Here Insert Picture Description
Here Insert Picture Description

Click the file, right
Here Insert Picture Description

Run the program, view the output:
Here Insert Picture Description

Two, java program basis

Third, the production process

Fourth, the array operations

Released eight original articles · won praise 3 · Views 276

Guess you like

Origin blog.csdn.net/weixin_39079076/article/details/104631497