?Java测试一元运算符

2019年2月11日22:29:37 发表评论 907 views
/**
 * Created by xabcd on 2019/2/11.
 */
public class TestJava3_14
{public static void main(String args[])
{
    byte a = java.lang.Byte.MAX_VALUE;
    boolean b = false;
    System.out.println("a = "+a+",~a="+(~a));
    System.out.println("b = "+b+",!b = "+(!b));
}
}




结果:
a = 127,~a=-128
b = false,!b = true

~取补码

发表评论

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: