public static void main(String[] args) { char x = 'x'; int i = 10; System.out.println(true? x : i); //120 System.out.println(true? 'x' : 10); // x } /* * 如果其中有一个是变量,按照自动类型转换规则处理成一致的类型; * 如果都是常量,如果一个是char,如果另一个是[0~65535]之间的整数按char处理; * 如果一个是char,另一个是其他,按照自动类型转换规则处理成一致的类型; */
public class TestExer2 { public static void main(String[] args) { int week = 2; week += 100; week = week % 7; System.out.println("100天后星期" + week); } }
int m = 3, n =5; ------------------------- 方式一: int temp = m; m = n; n = temp; 方式二: m = m + n; n = m - n; m = m - n; 方式三: m = m ^ n; n = m ^ n; m = m ^ n;