2 Chapter Summary

Source: Internet
Author: User
Tags arithmetic operators bitwise operators

Keyword: cannot be used for variable name, class name, object name, method name, and so on.

Identifier naming rules: Identifiers cannot be keywords, true, false, null.

Identifiers can contain numbers, letters, underscores, dollar signs.

The first character must be a letter, underscore, or dollar sign.

Case sensitive, variable name starts with lowercase, no maximum length is specified.

In the middle of the name, there can be no space. Adhere to the Hump naming law.

Java is a strongly typed programming language, which means that all variables used in a Java program must have well-defined data.

Eight Big data types

1, byte 1 byte 8 bit

2, short 2 bytes 16 bits

3, int 4-byte 32-bit integer constant defaults to int.

4, long 8 bytes 64 bits

5, char 2 bytes 16 bits

6, float 4 bytes 32 bits

7, double 8-byte, 64-bit floating-point constants default to Double.

8, Boolean for logic operations, generally used in program flow control. Only values of TRUE or false are allowed.

Reference type

such as: String

Constant

The value of the constant does not change. A constant is added when declaring a variable with the final keyword.

Type conversions

The small-capacity type is automatically converted to a large data type, and the large-capacity type is converted to a small data type. The Boolean type cannot be converted to another data type.

Operator

Arithmetic operators: Standard math operator.

+ addition operator

-Subtraction operator

* Multiplication operator

/Division Operator

% modulo operator

+ + increment operator

--Decrement operator


Relational operators: simple arithmetic symbols.

< less than

> Greater than

<= less than or equal to

>= greater than or equal to

= = equals

! = does not equal
Logical operators: The ability to make multiple comparisons and combine the results into a single Boolean value.

&& Logic and

|| Logical OR

! Logical non-single-mesh operators
Bitwise operators: When working with integer data, you can directly manipulate the individual bits that make up an integral type value.

& Bit and

| bit or

^ XOR or

~ Bit non-


Assignment operator: Assigns a data to a variable.

int a=1; Indicates that a value of 1 is assigned to a.
Extended assignment Operator: A shortcut for manipulating the assignment operator and other operators.

+ = A+=b a=a+b;

-= A-=b a=a-b;

*= a*=b a=a*b;

/= a/=b a=a/b;

%= a%=b a=a%b;

String Join operators

String name= "Hello" + "world";
Conditional trinocular operation symbol: A quick mechanism of IF/ELSE control statement.

Expression 1? Expression 2: Expression 3;

Input, output.

Input: Scanner sca=new Scanner (system.in);

Output: System.out.printlen ();

2 Chapter Summary

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.