Basics of JAVA

Source: Internet
Author: User

A review of yesterday's knowledge, such as the JDK JVM JRE and so on, is reviewed systematically.

Data types for two Java

1. Basic data types (such as int/char/byte/short, such as numeric types)

2. Reference types

* Classes in the API, such as String, File

* Custom classes, such as Personalaccount,creditaccount

* arrays, such as int[],string[]

The value range, type conversion, and understanding application of the three basic data types are as follows:

1 "8 basic data types/digits": (BYTE/8) (SHORT/16) (INT/32) (LONG/64) (FLOAT/32) (DOUBLE/64) (CHAR/16) (BOOLEAN/1)

2 There are two types of data type conversions:

Automatic type conversion (implicit type conversion)

such as: float f = num; Double d = f;

Forcing type conversions (explicit type conversions)

such as: int x = 65; char ch = (char) x; (because the char type is less accurate than the int type, the compiler cannot convert it automatically and can only cast)

Four-pack concepts, functions, naming conventions, and use

Concept: A collection of classes that are physically folders that logically have a logical relationship.

Role: Avoid class name, control access rights.

Naming conventions: In the name of the package, you can use the. Number to differentiate the level of the package, and the package name is usually lowercase.

The first level refers to the type of the project, such as com,org,gov, etc.

The second level refers to the company name that the project develops or runs, such as: Chinasofti,icss,huawei, etc.

The third level refers to the name of the project, such as: COREJAVA,BCMS,OA,ERP, etc.

The fourth level refers to the project module name, such as: Bean,action,exception,chapter01, etc.

For example: public class AAA {

public static void Main (string[] args) {
System.out.println ("I can learn the Java language well");

}

}

The five-access modifier (public, protected, (default), private) four permission access modifiers, arranged in order from large to small.

Encapsulation in the six Java classes

Encapsulation is a kind of information hiding technology

1 All the properties of the object and all the methods are combined to form an indivisible independent unit.

2 Hide the internal structure of the object as much as possible.

For example, use the public permission:

public class trainer{

private String name; Public String GetName () {

return name;

}

public void SetName (String name) {

THIS.name = name;

}

}

Seven Java expressions (a sequence consisting of a series of identifiers and operators)

Expression: Comma expression: variable defined by function separation

Question-Mark expression (ternary operator)

Logical expression (logical value, that is, "true" or "false")

Eight identifiers

Concept: In the Java language, for variables, constants, methods, all names are called Java identifiers, and identifiers are used to name classes, objects, methods, variables, interfaces, and custom data types.

Naming rules and naming conventions

Nine use of semicolons, keywords, blanks, curly braces, etc.

Semicolon: In Java, some characters are used as delimiters, and the most commonly used separators are semicolons (;), which are used to separate statements.

Whitespace: When you encounter an operator in your code, such as =, leave spaces on both ends to enhance the readability of your code.

{} curly braces: The values used to include an automatically initialized array are used to define the block, class, method, and local scope of the program.

Single-line Comment

/* Single, multiline comment */

/** Document Comments */

Basics of JAVA

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.