1.不使用额外变量而变换两个变量值
public static void main(String[] args) { int a = 3; int b = 4; a = b +(b = a)*0; System.out.println("a = "+a); System.out.println("b = "+b); }
2.斐波那契数列
public static void main(String[] args) { int a =1; int b = 1; while(b > 0){ //b溢出时终止 System.out.println(a); b = a+(a = b); } }