Chapter 2 knowledge points

Source: Internet
Author: User

1. The String constant uses double quotation marks as the separator of the string.

Format: it can contain numbers, punctuation marks, null, and other special characters,

2. What are the similarities and differences between the print and println methods?

A: Similarities: the print and println methods represent the two services provided by the system. Out object.

Difference: the print cursor will not move to the next line

The println cursor moves to the next line.

3. String concatenation operator?

A: The String concatenation operator is "+ ".

4. Escape sequences are used to indicate special characters that may cause compilation errors.

Escape Sequence in Java

5. variables, assignments, and constants

A: A variable represents the memory unit for storing data. The variable name is the symbolic address of the memory unit.

 

Eg: int total; // declare an integer variable

Double num1, num2 = 4.356, num3; // declare a Boolean variable

Char letter = 'A', digit = '7'; // declare a character variable

Final int max = 45; // declare a constant integer variable

Value assignment: Reading data does not change its value in memory, but the value assignment statement overwrites the old data.

 

Constant: a specific value is saved during existence.

Reserved word of a constant: Final

Variable name of a constant: All values must be in uppercase.

// Declare a constant integer variable and assign 27 values to the variable

Eg: Final int max_occupancy = 27;

6. Basic Data Types

Eight basic data types: Four integer types, two floating point types, complex type and boolean type.

Four integer types: byte, short, Int, and long character type: Char. Note: single quotes are used to indicate the character constants such as 'B ',';',''.....

Two floating point types: float and double Boolean: Boolean. Note: The result is only "Turn" or "false ".

 

Chapter 2 knowledge points

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.