Java if简单用法

2019年2月12日21:39:31 发表评论 1,058 views
/**
 * Created by xabcd on 2019/2/12.
 */
public class TestJava_f
{public  static void main(String[] args)
{
    int a = 6, b = 5;
    System.out.println("a = "+a+",b = "+b);
    if (a>b)
        System.out.println("a -b = " +(a-b));
    System.out.println("a*b = "+(a*b));
    
}
}
//若是if语句要处理的语句只有要给,可省略左右大括号
结果 a = 6,b = 5 a -b = 1 a*b = 30

发表评论

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