运算符“/”

在Java中,使用算数运算符+、-、*、/、表示加、减、乘、除运算。当参与/运算的两个操作数都是整数时,表示整数除法;否则,表示浮点除法。

代码验证:

public class Test01{

  public static void main(String[] args){

    int a=5;

    int b=2

    System.out.println("a/b");

  }

}输出结果为2

 

public class Test02{

  public static void main(String[] args){

    int a=5;

    double b=2;

    System.out.println("a/b");

  }

}输出结果为2.5

posted on 2017-07-20 20:17  Vic丶绅士  阅读(28117)  评论(0编辑  收藏  举报

导航