Java Learning Note day02

Source: Internet
Author: User
Tags arithmetic operators

1. Manifestations and characteristics of various forms of production
each binary, x into the full x into one
Binary : represented by 0 and 1, beginning with 0b in Java
Octal : Represented by 0~7, 0 opening
decimal: Natural number
16 binary: With 0~9 and A~f, the beginning of 0x
2. Conversion methods between various systems
Decimal -centric, decimal-to-binary: The decimal number is divided by 2, and the remainder is arranged in reverse order;
other conversions to decimal: You multiply the values by the sum of the weights, for example, the binary, from left to right, the 2^0,2^1,2^2 analogy, and the other in the substitution power;
Binary conversion to octal or hexadecimal; the three-digit binary number represents an octal; the four-digit binary number represents a hexadecimal;
3. Finding negative numbers in the computer's form of expression
Negative number: First, regardless of the positive or negative numbers are decimal numbers, the decimal number in the computer with a binary number, a positive ignore the symbol value according to the ordinary conversion rules, negative numbers, first take the value into binary number, and then take the inverse +1;
4. To find the corresponding integer according to the binary number
Binary conversion to decimal when the first look at the sign bit, then the conversion, positive, ordinary rule, negative: first to determine the symbol is negative, and then minus 1 to reverse the value;

5.Java Naming specification:
Package name is all lowercase,
Class name first Letter capital
Method names such as: Addstunumber;
6. The nature of the variable:

Accessing and modifying in-memory data

7. variables to be assigned before use;
the default type for integers is int;

Byte (one byte -128~127)

Float type definition must add f/Precision 7 bits, the default type is double/precision 16 bits;
Long definition preferably plus l; when defined, the default type is int, which goes wrong when the int range is exceeded;
Long lo = 4545121454;//error
Declares that a long constant must be followed by an ' l ' or ' l '
Long lo = 4545121454L;

8. Conversion of each type
Char,byte,short, etc., are automatically converted to int type in the operation.
A long conversion to float can be done, but the precision will be lost;
Char defines a single character, a Chinese two byte, (char can be represented by a 16-bit binary) to define a four-bit hexadecimal Unicode code;
9. Arithmetic operators

The plus sign is a connector that is generally performed mathematically; plus double quotes, string overloading, string join operations
Plus and single quote characters, for example: ' A ' +5; the result is 102;

10. Decimal negative numbers are stored in the computer with the complement;

11. Logical operators

There are mainly with (short circuit and/or logic with), or (short circuit or/logic or), non, with or;

&& Short circuit and;& logic with; difference: short-circuit with, if the previous condition is false, the back is not executed;
|| short-circuit non; | logical non; the same; after the first condition has been processed, the result can be obtained and the latter condition will not be executed;
12. Sign bit operation:
In this operation, the number of all operations to be converted into eight-bit binary
Left-shift operation (<<) eight-bit binary number is moved to the left, the right vacancy is 0;
Signed right shift operation (>>) After right shift, left full with sign bit fill;

Unsigned right-shift operation (>>), filled with 0, usually used in int type operation, if byte type is used, it is first used int, and then when cast to byte type, high truncation, the final result is changed;

Java Learning Note day02

Related Article

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.