Java Foundation 1 (2015-8-2)

Source: Internet
Author: User

Knowledge Point Consolidation:

1. How to define variables and initialize them

Data type variable name = initialization data;

2. Scope of variables: Global variables, local variables.

Knowledge Points of Learning:

1. Conversion of data types:

The conversion of data types is divided into two main categories: automatic conversion, casting

1) Auto-convert (implicit conversion ): target type = original type. ---------------------- Knowledge point Truth . doc

Feature: Convert from a small range of data types to a wide range of data types. Byte the Short the Int the Long

Note: in Java ,when theByte/short/char is evaluated, it converts itself to the int type before calculating.

2) forcing data type conversions

Note: You should use caution, the problem of poor accuracy of results when casting, or the information of error.

2. Operators

Arithmetic operators, assignment operators, relational operators, logical operators, bitwise operators, (ternary operators)

1) Arithmetic operators:+,-,*,/,%,--,++,+(String connector). ++before a variable equals: The variable itself+1, and then perform other operations. int num1=num++;after the variable is placed, the other operation is done first, and the variable itself+1.

2) Assignment operator: = , += -= , *= , /= %= num+=2; num=num+2;

3) relational operators:= =,! =,>,<,<=,>= . The result of a relational operator operation is a Boolean. Use range: expressions, looping statements, and so on.

Java Foundation 1 (2015-8-2)

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.