JAVA Arithmetic Operators, Relational operators, bitwise operators, and java Arithmetic Operators
Arithmetic Operators
1. java Arithmetic Operators include + (plus),-(minus), * (multiplication),/(Division), and % (remainder ), the implicit conversion principle in the operation process is the same as that in the C language;
2. Forced conversion is required for converting high-level data to low-level data;
Relational operators
1. java Relational operators include >,<>=, <=, =, and ,! =, The use rules are the same as those in the C language, and there is also a short circuit principle in complex relational computing statements;
2. The output result of the java logic operation can only be false or true, and the result is of the boollean type. This is different from the C language!
Public class Operator {public static void main (String args []) {System. out. println ("10> 5:" + (10> 5); System. out. the result of println ("10> = 5 is:" + (10> = 5); System. out. println ("10 <5 Result:" + (10 <5); System. out. println ("10 <= 5:" + (10 <= 5); System. out. println ("10 = 5:" + (10 = 5); System. out. println ("10! = 5: "+ (10! = 5 ));}}
Bitwise operators
1. java bitwise operators include: & (and) | (OR )~ (Not) ^ (exclusive or );
2. Operators that contain bitwise operators convert data into binary values during operations;
3;
|: Convert the two data for calculation into binary data, and then calculate the corresponding BIT data. One of them is 1, which is 1;
^: Convert the two data for calculation into binary data, and then calculate the data on the corresponding bit. The difference is 1, and the same value is 0;
~ : Convert the two data for calculation into binary data, and then calculate the corresponding bit of data, each bit is reversed;
public class ByteOperator{ public static void main(String args[]) { System.out.println("0 and 0\t"+(0&0)); System.out.println("0 and 1\t"+(0&1)); System.out.println("1 and 0\t"+(1&0)); System.out.println("1 and 1\t"+(1&1)); System.out.println("-------------------"); System.out.println("0 or 0\t"+(0|0)); System.out.println("0 or 1\t"+(0|1)); System.out.println("1 or 0\t"+(1|0)); System.out.println("1 or 1\t"+(1|1)); System.out.println("-------------------"); System.out.println("0 XOR 0\t"+(0^0)); System.out.println("0 XOR 1\t"+(0^1)); System.out.println("1 XOR 0\t"+(1^0)); System.out.println("1 XOR 1\t"+(1^1)); System.out.println("-------------------"); System.out.println("~0\t"+(~0)); System.out.println("~1\t"+(~1)); }}