Keyword identifier comment constants and variable operators

Source: Internet
Author: User
Tags bitwise comments constant logical operators true true

The keyword is lowercase and the first letter of the class name is capitalized.

Two. Identifiers can only be made up of 26 English letters, numbers, underscores (_), Dollar signs ($). The number cannot begin, and the keyword cannot be used.

Three. 1. Note: Use "//" in front of Mark, single line mark, can only identify one sentence.

2. Multiline comment/* in the first line of the text that needs to be commented, and then add the line after the end of the text. Java-specific comments: the same line after the previous line, but the previous line is identified with/**. It has a special feature that can be extracted with javadoc to annotate something and generate a manual. This is a document comment.

3. Multiline annotations can be used to find errors in Java, because Java does not run it after the comment, so it can be used to find the wrong part of the comment. However, multiple lines of comments can not have multiple lines of comment, because a/** will go back to the * * As long as the found on the stop, so if there are multiple lines of comments in the comment, he can only run the first and the top end. Causes no errors to be detected. That is, the debugging of the program.

4. Comments are not compiled into bytecode.

Four. Constants and variables

1. Constants

1. Integer constants: Includes all integer (123456789......).

Binary issue: Octal identification 6 binary identification The 0x identifier is the identifier at the beginning.

Related knowledge in binary: Byte (byte) One byte equals eight binary, and one binary is a bit. Binary one with negative positive number is zero, 0 changes repeatedly plus 0000-0001

2. Decimal constants: All decimals (**.**).

3. Boolean constant: True True false.

4. Character constants: Numbers (0 1 2 3 4 5 6 7 8 9) letters (single letter) symbols (+-*/) enclose individual letters or numbers in single quotation marks (').

5. String constants: Use double quotation marks ("") to cause one or more characters. "" Empty string.

6.NULL constant: Only one data is null.

2. Variables

1. When to use variables: use variables when there is an indeterminate amount.

2. How to use variables:

3. Data type:

1. Basic data types

1. Numerical type

1. Integer type

1.byte:8 bits

2.short:16 bits//integer default int

3.INT:32 bits//coercion type conversion byte b=2; b= (Byte) (b+4) This will discard the previous binary if the number is too general to cause

The result is wrong.

                            4.long:64 bits                            ,         &NB Sp                               //int a number x After calculating the x becomes a decimal, the decimal number will be eliminated automatically. Eg:int x=1234 x/1000;system.out.println (x)        output 1             &NBS P                          ,         &NB Sp                       

2. Floating-point type floating point: The more the decimal point number the more accurate//% (take remainder, modulo operation) in System.out.println (x%y); then click Run to display the remainder.

1.float: four bytes//decimal default double

2.double: Eight bytes//system.out.println ("x" +y); X is you want your computer to print , y is what the computer knows.

2. Character type

1.char: Two bytes A Chinese character two bytes//If the number is too large or the format is not correct, you can add the initial letter of the base data type after the number.

3. Boolean type//system.out.printl N ("x" + "\ n"), and then add \ n will be the next line in an empty line.

1.boolean: True and False value

(+ +,--) + + self-increment, b=a++; Operation Process: First save the original value of a, then a self-increment, and then the original value of a is assigned to B.

B=++a: The first increment of a, and then the value of a is assigned to B.

(+=,-=,*=,/=) The difference between the + = operation and the x=x+1 operation: If the character type is not appropriate, + = automatically casts the action. X=x+1 Similar operations can not be automatically converted, causing the former to pass while the latter error.

3. Operators

1. Compare operators <, >, = =. Comparison operators have a definite result when compared.   Result: true, false. = =: Judge before and after two is equal. =: Not equal to.

2. Logical operators & (with), | (or), ^ (also or),. (non), && (short), | |  (OR short circuit). An expression that is used to connect two Boolean (Boolean) types. ^ also or: Both sides of the judgment are true or both are false, the result is false. True if both sides are judged differently: true=false,!! True=true. && If the previous Boolean type expression is wrong, the latter is no longer judged to be correct.

3. Bitwise operator (bit: bits). &: 0 is False, 1 is true. X&y in the bitwise operation, the X and Y are restored to binary, and then the & is performed by the same bit. Several others are the same. ~ Anti-code: is the binary 1 variable 0,0 change 1.

Shift operator: is the movement of the binary position, moving the entire 32 bits to the left or right n bits.  More than the original binary location of the number of discarded, the right blank position with 0, if the right shift if the original binary first is 1 take 1, for 0 to take 0 to fill. The use of shift operations: Left n is equivalent to the original number multiplied by two of the n-th square.    Conversely, if you move right, you can divide the nth side of the second. The difference between >>> and >>: The left empty space after the right shift.

Swap the values of two numbers without adding a third-party variable: a=a^b;b=a^b; a=a^b;

4. Ternary operator: Three elements participate in the operation. Ternary operator: (. Expression 1: expression 2;) The question mark is the true expression 1, and the question mark is the pseudo-operation expression 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.