White Tour 1

I. Introduction

1.1 Java language Overview

1.1.1 What is the Java language

SUN Java language developed by the United States (Stanford University network), launched in 1995, high-level programming language.

  • 2009, Oracle's acquisition of SUN Company, introduced the Java 7.
  • 2014 released Java 8.
  • 2017 released Java 9.
  • 2018 released Java 10.

1.1.2 Java can do

Java language mainly used in Internet applications (mobile terminal), big data and data mining.

Computer basics 1.2

1.2.1 Binary

Decimal life generally, including 0 to 9, every decimal;
computer using binary, containing from 0 to 1, every binary one.
Each is called a 0 or 1 bit (bit).

  • Binary -> Decimal
    • Calculating a power sum of the use position is multiplied by 2
  • Decimal -> Binary
    • The data continue to acquire the remainder divided by 2, when the quotient is zero, ending;
      the final outcome of the remainder written backwards.
    • Binary

1.2.2 computer data storage units

  • Byte (Byte) is the smallest storage unit computer.
  • 1 byte consists of 8 (bits) bits. 1Byte = 8bit
  • Octal: 0 to 7
  • Hex: 0 ~ 9, A, B, C, D, E, F
  • Features: The higher the band, the number of bits of the same data used by the less

1024Byte = 1KB
1024KB = 1MB
1024MB = 1GB
1024GB = 1TB
...
PB
EB
ZB

1.3 DOS command

MS-DOS
early DOS systems are combined using some specific instructions to make a computer response occurs.
For developers, the actual work, mainly used IDE (integrated advanced compiler tools, eclipse, idea) to develop.
But the entire process needs to know to run a Java program of learning, so let's use the DOS command.

  • Start dos: win + r, input cmd
  • Switching disk: Disk name:
  • Into the folder: cd folder name
  • And entering the folder: cd folder 1 \ Folder 2 ...
  • Returns the root directory: cd
  • Quick Tip: Enter some of the content is started, press the tab key
  • Executable file: Switch to the folder where the file, enter the file name directly
  • View the contents of the current folder: dir
  • Clear the screen: cls
  • Exit: exit

1.4 build Java programming environment

What is the 1.4.1 JDK

  • JDK: Java Development Kit Java Development Kit
  • JRE: Java Runtime Environment Java Runtime Environment
  • JVM: Java Virtual Machine Java Virtual Machine
    Note: JDK includes JRE, JRE included JVM

1.5 Java language features

1.5.1 cross-platform

Java programs can only write once, run on any different operating systems.
JVM provides cross-platform.

JDK 1.5.2 Download

Go to the official website to download, see Fig.

Download jdk1

Download jdk2

Download jdk3

1.5.3 JDK installation

See Fig.

Installation jdk1

Installation jdk2

Installation jdk3

Next no brain, can also modify the path
Note: JDK and JRE installation path can not have Chinese

1.5.4 Test installation was successful

In cmd, Java or Java -version input instructions,
if the corresponding message, the installation is successful.

II. The first Java program

2.1 Development Process

After the first compile and run

2.1.1 write source code

Prepared in Notepad
public the HelloWorld class {
      public static void main (String [] args) {
             System.out.println ( "fifty - fifty");
      }
}
The suffix .java files to

2.1.2 compiler

  • Use javac instruction, JVM will .java .class files compiled into executable (binary byte code) files

2.1.3 Operation

  • Use java command, run .class file

Configuration 2.2 environment variables

  • We need to not only run the javac command in the bin, any position in the computer can run
  • Computer -> Properties -> Advanced System Settings -> Advanced -> Environment Variables -> variable in the system configuration, see FIG.
  • Configuration environment variable 1
  • 2 configuration environment variable

III. Comments, keywords, identifiers

3.1 Notes

In the text of the program code of explanation: Concepts
features: the program is running, not running the annotation content
formats:
1. Single-line comments: // annotation content
2. Multi-line comments: / * * footnotes /

3.2 Keyword

Concept: In the Java language has been predefined Well, the English word that has special meaning
characteristics:
1. all lower case
2. In the advanced editing software, showing a special font style
, for example:
public static void class
int byte Long Short
Double char boolean float
the extends the implements abstract
the synchronized

3.3 Identifier

Concept: In the code, we define our own name, for example: class names, method names, variable names, and so on.

Naming rules:
1. Composition: letters (case sensitive), numbers, the dollar sign $, underscore _
2. The numbers do not begin with
3. must be unique keyword

Naming convention:
1. class name, interface name: capitalize the first letter of each word capitalized behind the (large hump)
2. variable names, method names: lowercase first letter of each word capitalized behind ( small hump)
3. constant name: All letters are capitalized, with an underscore _ connections between multiple words
Note: see the name to know Italy, semantic

IV. Constants

Concept: During the program run, you can not change the value of

Classification constant
1. integer constants: integer
2. decimal (floating point) const: All numbers with decimal points, for example: 3.0
3. character constants: a single character enclosed in single quotes up, and only one, for example: 'a', '+', '', ' day', '9'
4. Boolean constants: only two values, to true, to false
5. the string constants: double quotes string of characters, for example: " helloworld "," Zhao day day "
6. empty constants: null, said there is no data

V. Data Types

Concept: different types of data of
the data types fall into two categories:
1. Basic Data Type
2. The reference data types

5.1 Basic Data Types

Eight kinds of four categories

5.1.1 integer type

  • byte
    byte, 1 byte, -128 to 127
  • short
    short integer, 2 bytes, -32768 to 32767
  • int
    int, 4 bytes, 2 ^ -2 ^ 31-1 ~ 31 is
    the Java integer in the default
  • long
    long integer, 8 bytes -2 ^ 63 to 2 ^ 63-1

5.1.2 Floating Point Types

  • float
    Single-precision floating point type, four bytes
  • double
    Double-precision floating point type, 8 bytes
    in Java floating point type default

5.1.3 Character Types

  • char
    char, byte 2, 0 to 65535

5.1.4 Boolean

  • boolean
    boolean, a byte, only true and false

Notes:
1. The basic string data type is not, is a reference type
2. The floating-point type is an approximation and not exact value
3. The default value is integer int, float default value is Double
4. If the integer exceeds int range needed at the end plus L / l; if the fractional float is not intended to represent a double, necessary to add F / f at the end.
The numerical value of the order types: double> float> long> int > short> byte

VI. Variables

Concept: within a reasonable range, changing data values

Variable Format definitions:
1. create, after the assignment
data type variable name;
variable name = value;

2. Create the same time assignment
of data type variable name = value;

Notes:
1. not create multiple variables of the same name
2.float need to add F / f; long need to add L / L
3. Data values can not exceed the range of the type of
a variable assignment can not be used 4. No
5. The only variable It can be used (scope) in the range in which it is created

Guess you like

Origin www.cnblogs.com/demonycw/p/11312111.html