Java基础(三)
自增、 自减、
package operater;
public class Demo04 {
public static void main ( String[ ] args) {
int a = 3 ;
int b = a++ ;
System. out. println ( a) ;
int c = ++ a;
System. out. println ( a) ;
System. out. println ( b) ;
System. out. println ( c) ;
double pow = Math. pow ( 2 , 3 ) ;
System. out. println ( pow) ;
}
}
逻辑运算符
package operater;
public class Demo05 {
public static void main ( String[ ] args) {
boolean a = true ;
boolean b = false ;
System. out. println ( "a && b:" + ( a && b) ) ;
System. out. println ( "a || b:" + ( a || b) ) ;
System. out. println ( "!(a && b):" + ! ( a && b) ) ;
int c = 5 ;
boolean d = ( c < 4 ) && ( c++ < 4 ) ;
System. out. println ( d) ;
System. out. println ( c) ;
}
位运算符
package operater;
public class Demo06 {
public static void main ( String[ ] args) {
System. out. println ( 2 << 3 ) ;
}
}
package operater;
public class Demo07 {
public static void main ( String[ ] args) {
int a = 10 ;
int b = 20 ;
a+= b;
a-= b;
System. out. println ( a) ;
System. out. println ( a+ b) ;
System. out. println ( "" + a+ b) ;
System. out. println ( a+ b+ "" ) ;
System. out. println ( a+ b+ "" + a+ a) ;
System. out. println ( a+ b+ a+ "" + a+ b+ "" ) ;
}
}
package operater;
public class Demo08 {
public static void main ( String[ ] args) {
int score = 50 ;
String type = score < 60 ? "不及格" : "及格" ;
System. out. println ( type) ;
}
}