Java common sense and data types

Source: Internet
Author: User
Tags java keywords

The download, installation, and environment variables of the JDK were last introduced. This time we'll talk about Java's common sense and Java data types;

Common Java Development tools

Editor:

1:ultraedit;

2:editplus, etc.;

Integrated development Environment:

JBuilder (http://www.borland.com);

Eclipse (http://eclipse.org), etc.;

Main content;

1. Identifiers;

2. Keywords;

3.Java basic data type;

4. Operators;

5. Expressions and statements;

6. Branches;

7. Circulation;

8. Methods;

9. Scope of variables

10. Simple recursion;

Identifier:

In the Java language, names of features such as variables, methods, and classes are used as sequences of characters called identifiers;

The Java identifiers have the following naming conventions:

1. Identifiers are composed of letters, underscores "_", "$" or numbers.

2. Identifiers should be preceded by letters, underscores, dollar signs;

3Java identifier case sensitive, length five limit;

4. Conventional: Java identifier selection should pay attention to "see the name of" and not with the Java language keyword duplicate;

Key words:

Some special meanings are assigned in Java, and strings used for specialized purposes are called keywords;

1. All Java keywords are lowercase english strings;

2.goto and const, although never used, are also retained as Java keywords;

Java constants:

The constant value of Java is represented by a string, distinguishing between different data types.

1. If the shaping constant: 123;

2. Real-type constants: 3.14;

3. Character constant: ' A ';

4. String constants: "HelloWorld";

5.null;

Note: Distinguish between character constants and string constants;

Java variables:

Java variable is the most basic storage unit in the program, which mainly includes variable name, variable type and scope;

Java program China each variable belongs to a specific data type and must be declared before it is used, for example:

int i = 100;

float f =12.3f;

Double d = 0.123;

String s = "Hello";

In essence, a variable is actually a small area of memory, with a variable name to the visitor block area,

Therefore, each variable must be applied before the application (Declaration), and then must be in the assignment (padding content), in order to use;

Categories of variables:

1. Press the declared location:

(1), local variables: variables defined inside a method or block of statements;

(2) member variables: Also known as local variables, external methods, variables defined internally by the class

Note: The outside of the class (outside the braces corresponding to the class) cannot have the declaration of the variable;

2. The type of data that the word belongs to is divided:

(1) Basic data type variables;

(2) Apply data type variable;

Partitioning of Java data types:

Scope of the Java base data type:

Default values for Java base data types:

Java Basic data type:

There are 4 classes of 8 basic data types defined in Java:

1. Logic type--boolean;

2. Character type--char;

3. Numerical type

(1) integer type--byte,short,int,long;

(2) floating-point type--float,double;

Logical Type Boolean:

Boolean types are generally suitable for logical operations and are generally used for process control;

Boolean data only allows true to be false, and cannot replace true and false with integers 0 or 0, which differs from C language;

Character Char:

Char-type data is used to denote "characters" in the usual sense;

Character constants are single characters enclosed in single quotation marks;

Integer type:

Java each integer type has a fixed number of table range and field length, it is not affected by the stop operating system, to ensure the portability of Java programs;

The integer constants of the Java language default to int, declaring a long constant followed by ' l ' or ' l ';

Floating-point types:

The Java floating-point constant defaults to double, and if you want to declare a constant of type float, you need to call ' F ' or ' F ' after the number;

Java common sense and data types

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.