Comparison operator SYSTEM.OUT.PRINTLN ("1! = 0 =" + (1!=0)); System.out.println ("1 > 0 =" + (1>0)); string GG = "SDSD"; String ff = "SDSD"; logical operator int BIJIAO1 = 10; int Bijiao2 = 0; int Bijiao3 = 20; && Short-circuit notation: Judging from left to right, as long as there is a false, then the result will be directly output, will not continue the backward operation//logic and Operation System.out.println ("Tru E && true = "+ (true&&true)); System.out.println ("true && false =" + (true&&false)); System.out.println ("false && false =" + (false&&false)); System.out.println ("False && false && true =" + (False && false && true)); System.out.println ("True && true && false =" + ((bijiao1>0) && (Bijiao2 = = 0) && (bijiao (3<0))); // || Short-circuit notation: Judging from left to right, as long as there is a true, then the result will be directly output, will not continue the backward operation//logic or Operation System.out.println ("true | | TruE = "+ (true | | true)); System.out.println ("true | | false = "+ (true | | false)); System.out.println ("false | | false = "+ (false| | false)); System.out.println ("false | | False | | true = "+ (false| | False | | true)); Logical non-operational System.out.println ("!true =" +!true); System.out.println ("!false =" +!false); Ternary operator? : int f = 0; if (age >) {f=age; } else {f = 0; } System.out.println ("f =" +f); Operator Precedence class//data type conversion int DJD = 999; Implicit conversion of long GJD = DJD; explicitly convert int djd1 = (int) Gjd; Implicit conversion of float higher than long float fl = GJD; Double db = FL; System.out.println ("+db"); Branch Statement--IF statement if (true) If the middle of the parentheses is correct, then the code inside the curly braces is executed {}//Example int age = 13; if (age <) {System.out.println ("Hello, children)"; } else if (age >= && age <18) {System.out.println ("classmate, hello"); } else {System.out.println ("friend, hello"); }//Branch statement--switch statement int s = 20; Switch (s) {case://case is not supported after decimal input SYSTEM.OUT.PRI NTLN ("20s =" +s); Break Equivalent to an interrupt case 30://The constant part must be different System.out.println ("30s =" +s); Break Case 40:system.out.println ("40s =" +s); Break Default Other conditions System.out.println ("other =" +s); Break }
15.09.29