Package Collection;
Difference between division operation and remainder operation public class Div {public static void main (string[] args) {//TODO auto-generated method Stubint Int1=5;int I Nt2=2;double double1=2.0;//Division operation result System.out.println (INT1/INT2); System.out.println (int1/double1); /* * 2 * 2.5 *///% for redundancy Operation System.out.println (int1%2); System.out.println (double1%0);//nan: Non-number}}
The difference between package Collection;//++a and a++ public class Leijia {public static void main (string[] args) {//TODO auto-generated method stub int a=10; System.out.println (a++); System.out.println (a); System.out.println (++a); }} Ten /// 12
Package collection;//comparison operator public class Bijiao {public static void main (string[] args) {//TODO auto-generated method stub int int1=453;float float1=453f; System.out.println (INT1==FLOAT1);//==, the two sides can only be numeric types, as long as the values are equal, the data type can be different//output true}}
Package Collection;public class Logicoperator {public static void main (string[] args) {//TODO auto-generated method Stubi NT A=5;int b=6;int c=8;//&& comparison with &/ if (a>3 && b++>4)//{//system.out.println (A + " " + b);//}////here output results a=5 b=7//if (a>4 & ++c>2)//{//system.out.println (A + " " +c);//}////5 9// // || and | comparison//if (a>3 | | c++>3)//{//SYSTEM.OUT.PRINTLN (A + " " +c);//}///output: 5 8if (a>3 | c++>3) { System.out.println (A + " " +c);} Output 5 9} }
The difference between && and &, | | As with |, the future is illustrated by an example, when | As long as two operands (before and after operands), the first operand is true, the post operand does not operate, and | | The post-operand will operate regardless of whether the preceding operand is bit true.
Package Collection;public class Threecharacters {//Three mesh operator public static void main (string[] args) { int a=11; int b=12; System.out.println (a<b? "A is less than B": "A is greater than B"); The Trinocular operator form is: (expression)? If-true-statement:if-false-statement}}
Java operator--2017.08.01