字符串的加法"+“字符的加法”+"
package dujian;
public class One{
public static void main(String[] args){
String str1 = "Hello";
String str2 = "World";
System.out.prinln(str1 +str2);
String str3 = "年龄";
System.out.prinln(str3 + 19);
System.out.prinln(999 + "感冒灵");
System.out.prinln("11" + 22 + 33);
System.out.prinln(11 + "22" + 33);
System.out.prinln(11 + 22 + "33");
System.out.prinln("----------------");
int i = 10;
char c = 'A';
c = 'a';
c = 'B';
System.out.println(i + c);
}
}
条件运算符
package dujian;
public class Twe {
public static void main(String[] args) {
int i = 10;
int j = 20;
int k = 10;
System.out.println(i > j);
System.out.println(i > k);
System.out.println("-----------");
System.out.println(i < j);
System.out.println(i < k);
System.out.println("-----------");
System.out.println(i >= j);
System.out.println(i >= k);
System.out.println("------------");
System.out.println(i <= j);
System.out.println(i <= k);
System.out.println("------------");
System.out.println(i == j);
System.out.println(i == k);
System.out.println("------------");
System.out.println(i != j);
System.out.println(i != k);
System.out.println("------------");
int a = 333;
int b = 222;
int max = a > b ? a:b;
System.out.println("两个数值中较大的值:"+max);
}
}
逻辑运算
pulbic class yu{
public static void main(String[] args){
int i = 10;
int j = 20;
int k = 30;
System.out.println((i > j) & (i > k));
System.out.println((i < j) & (i > k));
System.out.println((i > j) & (i < k));
System.out.println((i < j) & (i < k));
System.out.println("---------------");
}
}
pulbic class huo{
public static void main(String[] args){
int i = 10;
int j = 20;
int k = 30;
System.out.println((i > j) | (i > k));
System.out.println((i < j) | (i > k));
System.out.println((i > j) | (i < k));
System.out.println((i < j) | (i < k));
System.out.println("---------------");
}
}
pulbic class yiwei{
public static void main(String[] args){
int i = 10;
int j = 20;
int k = 30;
System.out.println((i > j) ^ (i > k));
System.out.println((i < j) ^ (i > k));
System.out.println((i > j) ^ (i < k));
System.out.println((i < j) ^ (i < k));
System.out.println("---------------");
}
}
public class fei{
public static void main(String[] args){
int i = 10;
int j = 20;
int k = 30;
System.out.println((i > j));
System.out.println(!(i > j));
System.out.println((i < j));
System.out.println(!(i < j));
}
}
public class duanluyu{
public static void main(String[] args){
System.out.println((i > j) && (i > k));
System.out.println((i < j) && (i > k));
System.out.println((i > j) && (i < k));
System.out.println((i < j) && (i < k));
System.out.println("----------------");
System.out.println((i < 100) && (i++ > 100));
System.out.println((i > 100) && (j++ > 100));
System.out.println("i:"+i);
System.out.println("j:"+j);
}
}
public class duanluyu{
public static void main(String[] args){
System.out.println((i > j) || (i > k));
System.out.println((i < j) || (i > k));
System.out.println((i > j) || (i < k));
System.out.println((i < j) || (i < k));
System.out.println("----------------");
System.out.println((i < 100) || (i++ > 100));
System.out.println((i > 100) || (j++ > 100));
System.out.println("i:"+i);
System.out.println("j:"+j);
}
}