Basic summary of Java Learning

Source: Internet
Author: User

Variables in 1.java are categorized by data type class:Basic data TypesandReference Data Type(Arrays & Classes &interface)>basic data type integral type:byte(8bit) Short int(Default type)Long(add l/at the end of the valueL) floating point type:float Double(default type) character type:Char(‘ ‘, there must be a single quotation mark to denote the character, JS inside there is no specific requirement) Boolean type:Boolean(evaluates to TRUE or FALSE, as with JS)2. Binary decimal binary octal hexadecimal>Binary: The bottom of the computer is the binary to store, the operation of the>Binary storage at the bottom: positive numbers, negative numbers are stored and calculated in the form of complement (original code, inverse code, complement)>conversion between four types of binary3. Operation of the variable A. Automatic type conversion: Small capacity data types are automatically converted to large-capacity data types ShortS=12; inti = S +2; PS:a byte short char is calculated between the int type!So, s+2, must be int type B. Coercion type conversion: is the inverse process of a, using"()" to achieve a strong turn.
An operator is a special symbol that represents the operation, assignment, and comparison of data.Arithmetic operators:+ - +- * / % ++ --PS:1)/:inti = 12; i = I/5;//i=22)%: The last symbol is only the same as the modulus3) before + +: First +1, after Operation + +: first operation, after +1 4) +: String strings can only be concatenated with other data types, and the result is a string-type  assignment operator:
= += -= *= /= %=intI=12; I=i*5; I*=5;//Ibid .[Special] Shorts=10; s=s+5;//compile will error, the generated s should be int typeS= ( Short) (s+5);//OKs+=5;//S=s+5, but there is no error in compiling this, it does not change the data type of S

comparison operators (relational operators)
= = > < >= <= instanceof

the difference between ps:== and =
returns a Boolean value after the comparison operation
if (i>1&&i<10) {}//ok
cannot be written as if (1<i<10) {}
logical operators (both ends of the operator are Boolean values)
& && | | ^ ^ (or, same take 0, different take one)!
PS: Distinguish between & and &&, and | | | The difference
When we use, choose &&,| |

bitwise operators (data of numeric types on both ends)
<< >> >>> & | ^ ~ (reverse)
PS:1) Here, move left, move to the right, the twos complement, the final result depends on the binary changes,
2) >&gt, move right, left with the number of sign bits to supplement, the right part of the removal is discarded
3) >>> also indicates right shift, but left unsigned right shift

[Example]1. How to convert values of m=12 and n=5
2. Convert 60 to 16 binary output

Ternary operators
(conditional expression)? Expression 1: expression 2;
1) Since it is an operator, a result must be returned, and the data type of the result is the same as the expression type
2) Expression 1 is consistent with the data type of expression 2
3) The use of ternary operators, must be converted to If-else, and vice versa not necessarily
Example: Get a larger value of two numbers; get the maximum of three numbers.

Basic summary of Java Learning

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.