JavaSE basic grammar

1. What is Java, why do I learn Java

Java is an object-oriented high-level computer language, repeatedly ranked first in the computer rankings over the years, so that we learn Java is a wise choice. In computer language class work pay first-tier cities has been in the middle and upper stage, so we have to learn Java.

Language features of 2.Java

Java program is not run directly, the Java compiler will compile the source code into Java byte code file (class files) and platform-independent bytecode file and then interpreted by the Java Virtual Machine (JVM) execution. Therefore, under different operating systems, simply install a different cross-platform Java virtual machine can be realized java program.

Features 3.Java language

1. Object-oriented
2. portability
3. Security
4. concurrency
5. supports visual graphical interface

4.DOS command

Before touching the integrated development environment, we need to use the command line window java program is compiled and run, we need to know some common DOS commands.

1, a command line window open manner: win + r open the Run window, enter cmd, Enter.

2, commonly used commands and their role

operating Explanation
Letter name: Switching letter. E: a carriage return, a handoff to the E drive.
to you View the contents of the current path.
cd directory Into the single-level directory. cd itheima
cd … Back to a previous directory.
cd directory 1 \ 2 directory ... Into the multi-level directory. cd itheima \ JavaSE
cd \ Fallback drive letter directory.
cls Clear the screen.
exit Exit the Command Prompt window.

Configuration 5.Path environment variables

1. The specific configuration procedures, see "Java environment variable configuration instructions" document.
2. Why configuration environment variable?
Development of Java programs, need to use the development tools (such as javac.exe, java.exe command, etc.) provided by the JDK, and these tools in the bin directory of the JDK installation directory, if you do not configure the environment variable, these commands can only be in the directory execution. We can not put all the java files into the bin directory of the JDK, so the configuration environment variable role is to make java related commands in the bin directory can be used in any directory.

6.HelloWorld Case

HelloWorld case is the output "HelloWorld" This line of text on a computer screen. A variety of computer languages used to using the case as the first presentation case.
1.Java run program development process
to develop Java programs, requires three steps: writing, compiler, run the program.
2. HelloWorld case of writing
(1) new text document file, change the name to HelloWorld.java.

(2) Open file HelloWorld.java Notepad, for writing the contents of the program.

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

3.HelloWorld cases compile and run
stored files, open a command line window, change the directory to the directory where the java file, the compiler generates a class file java file, run the class file.

Compiler: javac file name .java

Examples: javac HelloWorld.java

Execution: java class name

Examples: java HelloWorld

7.Notepad ++ installation and use

(1) Why should I use Notepad ++ software
Notepad ++ powerful than the built-in notepad windows functions, in addition to making a general text documentation is also very suitable for writing computer code. Notepad ++ have line numbers, to quickly locate the position of the problem, as well as syntax highlighting, code folding functions. And it's free.
(2) Notepad ++ software installation
Installation: Installation fool, has been the next step can be. Also recommended to install a unified development software directory, such as E: \ develop.

Specific installation procedures, see "Nodepad ++ software installation and configuration instructions" document.
(3) Notepad ++ Software Configuration
After installation, ease of use, make a simple configuration: modify the default language and encoding.

Specific configuration instructions, see "Nodepad ++ software installation and configuration instructions" document.

8.Java basic grammar

(1) Comment
Comments are code explanations and captions can improve the readability of the program, thus adding the necessary text annotation is very important in the program. Java comments in the following three:

Single-line comments. The format is to use single-line comments // // beginning to end of the line of text as the note text.

// 这是单行注释文字

Multi-line comments. Format is the use of multi-line comments / * and * / comment will enclose a longer period.

/*
这是多行注释文字
这是多行注释文字
这是多行注释文字
*/
注意:多行注释不能嵌套使用。

Documentation comments. Documentation comments to /**beginning to */end.
(2) Keyword
A keyword is a java language was given a special meaning to the word.

Key features:

Keywords all lowercase letters.

Common code editor keywords are highlighted, for example, now we can see the public, class, static and so on.
(3) Constant
Constant: the program is running, the value of the amount of change can not occur.

The constant in the Java Category:

String constants are more characters enclosed in double quotation marks (may contain zero, one or more), for example, "a", "abc", "China"

Integer integer constant, for example: and the like -10,0,88

Decimal constants decimal, such as: -5.5,1.0,88.88 etc.

A single quote character constant character enclosed, for example: 'a', '5', 'B', 'in', etc.

Boolean constants Boolean value that indicates true and false, only two values ​​true and false

A special air constant, null, null value

In addition to the space constant, other constants can be used directly output statements output.

public class Demo {
    public static void main(String[] args) {
        System.out.println(10); // 输出一个整数
        System.out.println(5.5); // 输出一个小数
        System.out.println('a'); // 输出一个字符
        System.out.println(true); // 输出boolean值true
        System.out.println("欢迎来到Java的世界。"); // 输出字符串
    }
}
Released three original articles · won praise 0 · Views 40

Guess you like

Origin blog.csdn.net/weixin_46666935/article/details/105237744