易混运算符

package day12;

/** 局部变量与成员变量 */
public class Test {

	/** 运算符 */

	public static void main(String[] args) {
		int i = 1;
		i += 1;// i=i+1 但是+=不考虑类型转换
		System.out.println(i);
		byte b = 1;
		b = (byte) (b + i);// 考虑类型转换
		System.out.println(b);

		b += i;// 不考虑类型转换
		System.out.println(b);

		// 三元运算:判断条件?结果1:结果2
		System.out.println(3 > 2 ? "大于" : "小于");

		int count = 0;
		System.out.println("count前:" + count);
		System.out.println("count++:" + count++);
		System.out.println("count中:" + count);
		System.out.println("++count:" + ++count);
		System.out.println("count后:" + count);
	}
}

  

猜你喜欢

转载自www.cnblogs.com/yueluoshuxiang/p/11367039.html