Java Basics Summary

Source: Internet
Author: User

1, Software: A collection of data and instructions organized in a specific order.

Software = instruction + data

2, the process of software development:

1. Clear the need: Be sure to do something; For example, to make an e-commerce website;

2. Determine what to do;

3. Specific coding;

4. Testing;

Professional terminology:

Clear business needs "finishing the logic" to complete the project "test" on-line maintenance + two development

3, the way of human-computer Interaction:

    1. Graphical interface (graphical user Interface GUI)
    2. Command line Interface CLI

4,java Language Platform Introduction:

    1. EE (Java 2 Platform Enterprise Edition) Corporate Edition
    2. J2SE (Java 2 Platform standard Edition) edition
    3. J2ME (Java 2 Platform micro Edition) Mini version

After the Java5.0 version, renamed: Java EE javase javame

Features of the 5,java language:

    1. Free Open-source
    2. Safe for
    3. Object-oriented
    4. Cross-platform

How is 6,java language implemented across platforms? ("Write Once, run everywhere")

The reason Java can be portable, mainly on the operating system (WINDOWS, Linux, MAC X) embedded in the JVM (Java Virtual machine), Java programs are portable.

The role and relationship of 7,JDK,JRE,JVM

JVM (Java Virtual machine):

Refers to a Java virtual machine, which is the most central part of the entire Java implementation cross-platform, all Java programs are first compiled into a. class file, which can be executed on the virtual machine;

JRE (Java Runtime Environment):

Refers to the Java Runtime Environment, where the JVM cannot complete class execution because the JVM needs to invoke the class library lib that is needed to interpret the classes, and the JVM and Lib are called JRE.

JDK (Java Development Kit JDK):

Refers to the Java SDK, where the JDK contains the JRE, and the JRE contains the JVM.

In general, the JDK is for the development of Java programs, while the JRE is only capable of running class without compiling. (JDK-----> JRE-----> JVM)

8, environment variable configuration

Method One:

Add the JDK Toolkit path at the English semicolon after the system variable path variable value.

such as C:\Program Files\java\jdk1.8.0_172\bin

Method Two:

Create a new system variable under system variables, such as:

Variable name: java_home

Variable Value: C:\Program files\java\jdk1.8.0_172\bin

After that, add%java_home% at the end of the value of the path variable.

9,java keyword Features:

Keywords are all lowercase, and the usage and writing of keywords are fixed.

10, identifier naming rules:

A, which can consist of uppercase and lowercase letters, numbers, underscores (_), Dollar signs ($)

B, numbers don't start.

C, keyword cannot be used

D, strictly case-sensitive

Note notation in 11,java:

Single-line Comment://commented content until the end of the line

Multiline Comment:/* Comment Text */

Document comments:/** Note text */(can be extracted by Javadoc tool to generate a help document)

12, the naming rules for constants:

Must consist of uppercase letters, if the word is divided by the underscore "_" between the words;

Constants define the syntax format:

Final constant type constant identifier = constant value;

For example: Final int week=7;

Basic data types in 13,java:

Integer type:

byte: one byte;-128 ~ 127; byte 8bit

Short: two bytes: -2^15 ~ 2^15-1; Short-integer 16bit

Int: four bytes: -2^31 ~ 2^31-1; Integral type 32bit

Long: Eight bytes: -2^63 ~ 2^63-1; Long-integer 64bit

In Java, integers by default are of type int;

Floating point type:

float: four bytes; -2^127 ~ 2^127;

Double: eight bytes; -2^1023 ~ 2^1023;

In Java, floating-point numbers are double by default;

Character type (char):

two bytes; 0 ~65535;

Must use single quotation marks in English, and only one character can be decorated

Boolean Type (Boolean):

True false;

14. Precautions for using variables:

1, variables are used in the scope: the use of variables in the middle of a pair of {};

2, before the use of variables, you must assign values;

3, assign a value to the variable, need to be consistent with the data type of the variable

15,java Data type conversions:

Automatic type conversion (implicit type conversion):

The data of a type with a small range of values is placed in a variable of a type with a large range of values, which can be placed directly in without loss of precision.

Coercion type conversions (explicit type conversions):

It is possible to put the data of a type with a large range of values into a variable of a type with a small range of values, and the loss of precision may occur.

If you have to put it inside, you need to use a method:

Small range of data type variable name = (small range of data type) variable name;

Note the point:

Integers in Java are int by default:

To declare a long type of constant, you need to add a letter after the number: L (both uppercase and lowercase)

Floating-point numbers in Java are double by default:

To declare a constant of type float, you need to add a letter after the number: F (can be uppercase and lowercase)

16, ternary operator:

Variable name = Boolean expression? Expression one: Expression two

17. Get Input information:

Import Java.util.Scanner;

Scanner scanner=new Scanner (system.in);

int A=scanner.nextint ();

Method functions

. Next () reads a string, and the string terminates when it encounters a space

. Nextbyte () reads an integer of type byte

. Nextshort () reads an integer of type short

. Nextint () reads integers of type int

. Nextlong () reads an integer of type long

. Nextfloat () reads an integer of type float

. nextdouble () reads an integer of type double

Types of program flow in 18,java

Sequential process: Is the default process of the program, do not need any control, as long as the writing, will follow the written code sequence execution;

Selection process: Need to write some control statements, there are two main: Judgment statement, select statement;

Repeating process: You need to write loop control statements.

Duplicate process keywords:

Break: Ends The current statement, used in switch and loop statements, and, in a nested loop, ends the loop closest to it by default.

Continue: Indicates the end of this cycle, continue the next cycle, will not affect the number of cycles;

19, the concept of function overloading

Concept: In the same class, you can define multiple functions with the same name and different argument lists, which is called overloading of the function. The overloads of the function are only related to the function name and the argument list, regardless of the return value type of the function.

20, the format of the array:

The first type:

data type [] Array name = new data type [capacity of array];

Data type array name [] = new data type [capacity of array];

The second type:

data type [] Array name = new data type []{element 1, Element 2, ...};

Abbreviated form:

data type [] Array name = {element 1, Element 2, ...};

Common exceptions:

ArrayIndexOutOfBoundsException (array subscript out-of-bounds exception)

NullPointerException (null pointer exception)

21, process-oriented and object-oriented differences

1. Different points of concern:

Process oriented: Care about how each step of the event functions;

Object-oriented: The concern is that each step in the event is there any object that has been implemented, and then used directly

2. Different efficiency:

Process-oriented: because they want to participate in each step of the implementation, so the efficiency is relatively slow;

Object-oriented: Because most of the functions that others have already achieved, the efficiency is higher.

3. Development quality:

Process oriented: Because it is a step-by-step implementation, most of the situation will be a problem;

Object-oriented: Because most of the functions that are written by others are called, and these features are generally verified by a lot of quality assurance

4, the scope of use is different:

Process oriented: Suitable to solve the problem of simple demand;

Object-oriented: more suitable to solve complex requirements;

Note: Object-oriented is based on process-oriented

Java Basics Summary

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.