JAVA Fundamentals 2

Source: Internet
Author: User

An. operator

1. Arithmetic operators:

    • +: plus or positive;
    • -: minus or negative;
    • *: Multiply;
    • /: except;
    • %: take surplus;
    • + +: Self-growth operator, written in front of the variable to indicate the first self-increment and then assign value, write after the variable to indicate the first assignment and then self-increment;
    • --: Self-reduction operator, usage same + +;

2. Relational operator: it must return a Boolean value;

< > >= <= = = =!

3. Logical operators:

! & (and); && (short circuit and) This differs from & in that if the operator returns false in front of it, the code behind is no longer running;

| or; | | (short circuit or);

^ OR: The variable is converted to 2, the same number of digits is 0, the number of different digits is 1, example: 2^3 output is 01;

4. Bitwise operators:>> << >>> (unsigned Right shift) ~ (opposite)

5. Assignment operators:

= + = = *=/=%= (modulo)

6. String Connection: + When the result is displayed, as long as a parameter is a string, the entire output is a string;

7. Ternary operator (expression) (trinocular operator):
Boolean value? Value 1: Value 2 Boolean is true return value 1;false return value 2;

8. Operator precedence (common)
1 ()
2 + +--~!
3 */%
4 +-
5 >> << >>>
6 < > <= >=
7 = = =!
8 &&
9 | |
103-tuple operator
11 Assignment operators

Two. Definition of variables

1. How variables are declared: variables that do not have an assignment in the underlying data type cannot be used;

int x;  int x = 5;   int x, y;  int x = 5, y;  int x = 5,y = 5; int x = y = z = 5; the first two types are generally used;

2. Character variable assignment:
char c = ' a ';
char c = ' Medium ';
char c = 98; 0-65535
char c = ' \ n '; Escape character
char c = ' \u0061 ';

3. Define an integer variable by default to int; Example: long L = 88888888888L;

4. Define a floating-point variable by default to double; example: float f = 12.345F;

5. Scope of variables
{code block} A variable declared in a scope can only be valid at this scope;

Eclipse Interface Description: The project browser on the left, the upper middle is the work area, the lower part is the error display area

Basic Main method format:

public class Test1 {public static void main (string[] args) {System.out.println ();//Shortcut Input SYSO Press and hold alt+/enter to quickly recall;}

JAVA Fundamentals 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.