Home >Java >javaTutorial >Master the basic syntax knowledge of java

Master the basic syntax knowledge of java

零下一度
零下一度Original
2017-06-25 10:34:591533browse

Goal: Master the basic syntax knowledge of java

1 Variable

Variables are changing quantities, and the values ​​in variables change. In java, use When declaring a variable, you need to declare a variable. When declaring a variable, you need to declare a variable name. The variable name must be a sequence of letters or numbers starting with a letter. There is no limit to the length of the variable name. When naming a variable, if there is only one word, it is all lowercase. If there are more than two words, the first word is lowercase and the first letter of the remaining words is uppercase. Keywords in Java cannot be used in variable names.

2 Data type

2.1 Integer type

Java is a strongly typed language, which means You must declare a type for each variable. There are 8 basic types in Java, including 4 integer types, 2 floating point types, and 1 character type.

## Data type: (1) Basic data type (2) Reference data type

#Basic data types: numerical type, character type (char), Boolean type (boolean) Numerical type: integer type (byte, short, int, long), floating point type ( float,double)

                                              AC [ ] Reference data type: class (class), interface (interface), array

Logical boolean

Boolean type data only allows the value true or false and cannot be replaced by 0 or non-0 integers for true or false

Text type char

Character constant is a single character enclosed in single quotes. The encoding format used is unicode encoding, and one character occupies two bytes.

Integer type (byte, short, int, long)

Char type occupies 2 bytesshort from -32768 to 32767

int ranges from -2147483648 to 2147483647, a total of 10 digits

long ranges from -9223372036854775808 to 9223372036854775807, a total of 19 digits


Three expressions of Java language integer constants

Decimal integer: such as: 13, -204,0.

Octal integer: required to start with 0, such as: 014.

Hexadecimal number: required to start with 0x or 0X, For example: 0X14.

Floating point type (float, double)

Java floating point type constants have two representation forms

Decimal number form: Such as: 3.45.

Scientific notation format: such as: 2.34e2

The above is the detailed content of Master the basic syntax knowledge of java. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn