Getting Started with Java Chapter II

Source: Internet
Author: User
Tags java keywords

Identifier: Declares the so-called class name, variable name, and so on.

Rules:

    1. Can be composed of letters, numbers, underscores _ and dollar sign $;
    2. Cannot begin with a number;
    3. Cannot use Java keywords;
    4. to have meaning;
    5. Capitalize the first letter of the class name;
    6. Use the Hump name method (e.g. Javascore).

There are two ways to define variables:

Data type

1. Variable name = value

Name variables while declaring them

Data type variable name

2. Variable name = value

Declare the variable, and then assign the variable as needed

What is a variable?

For example:

hotel room is variable

Room number room number is variable name

Room type room type is data type

The people who live live are the numbers.

The process of using variables:

    1. declare a variable;
    2. Assigned value;
    3. Use

Data type: base data type, reference data type (String)

Basic data type:

Values: integers, floating-point numbers

Non-numeric: boolean, character

Integers (byte, short, int, long)

Floating-point numbers (float, double)

Boolean "Boolean,true (True), False (False)"

Data conversion:

1. Same type;

2. Automatic conversion (low can automatically turn high), cast (High turn low (low type) can be converted);

Operator: + 、-、 *,/,% (remainder), = (Assignment operator)

Logical operator 1. "| |" : Or, take one of the two

    1. "&&" short circuit and both are satisfied.

Relational operators:! = (not equal to), >= (greater than or equal), <= (less than equals);> (greater than) < (less than) = (equals)

Scanner input = new Scanner (system.in);

(Receive keyboard input)

Int num =input.nextint (); [Convert int value]

(Next not only with int but also with other)

For example:

    1. Nextlong;nextdouble, wait.

Capitalize the first letter of the word after 2.next

Getting Started with Java Chapter II

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.