标签:
public class hello { /** * */ public static void main(String[] args) { //求模 System.out.println("20 % 7 = " +( 20 % 7)); int z = 10; z++;//z=z+1 System.out.println("z =" +z); System.out.println("z=" +z++);//先赋值再++ System.out.println("z =" + ++z);//先++再赋值 z--; //z=z-1 System.out.println("z =" +z);//System.out.println("z=" +z--); //System.out.println("z=" + --z); z=10; int k=z++; z += 2;//z=z+2 z -= 2;//z=z-2 z *= 2;//z=z*2 z /= 2;//z=z/2 z %= 2;//z=z%2 boolean luoji = true && true; System.out.println("true && true =" + luoji); luoji = true & false; System.out.println("true && false =" + luoji); luoji = false & false; System.out.println("false & false =" + luoji); luoji = ( 2 < 1 && 3 < 4);//“&&”是短路写法只要前面是false后面就不用算了,“&”要继续往后算 luoji = true || true; System.out.println("true || true =" + luoji); luoji = true || false; System.out.println("true || false =" + luoji); luoji = false || false; System.out.println("false || false =" + luoji); luoji = ( 2 > 1 || 3 < 4); luoji = !( 2 > 1 || 3 < 4);//反转 int p = 2 > 1 ? 1:2; System.out.println("p =" +p); String str =4>5 ? "asd" : "das"; int o = ((2 + 1)*(4 - 3)); System.out.println("k =" +k); System.out.println("z =" +z); System.out.println("10 > 9 =" + (10>9)); System.out.println("10 != 9 =" + (‘c‘ != ‘b‘)); // TODO 自动生成的方法存根 } }
标签:
原文地址:http://www.cnblogs.com/youshashuosha/p/5014267.html