Operators JAVA_day2_

Java Operators

First, arithmetic operators

++ and - can appear in both the left operand, may also appear on the right side, but with different results

1, ++ on the left, a first increment 1 and then assigned to b

int a=3

int b=++a

2, ++ on the right, the first assignment to b, a further increment 1

nt a=3

int b=a++

Note: The increment and decrement operators operating variables can only be used, or can not be directly used to operate a constant value.

 

Second, the assignment operator

 

Third, the comparison operator

Note:

1,>, <,> =, <= the number of right and left support only operation is a numeric type

2, ==,! = Operands on both sides may be either a numeric type, or a reference type

 

Fourth, the logical operators

 

V. conditional operator

Syntax: boolean expression? Expression 1: Expression 2

Operation: If the Boolean expression is true, the value of Expression 1 is returned, otherwise the return value of the expression 2

Column such as:

Score = 68 int;
String = Mark Score> = 60 "failed": "fail";?
( "How to test scores:" + mark) System.out.println;

Final output "fail"

 

Six, operator precedence

 

Guess you like

Origin www.cnblogs.com/melpython/p/11001298.html