Java强制类型转换

2019年2月11日22:42:45 发表评论 1,007 views
/**
 * Created by xabcd on 2019/2/11.
 */
public class TestJava3_15
{public static void main(String args[])
{
    int a = 13;
    int b = 4;
    System.out.println("a = " + a + ",b " + b);
    System.out.println("a/b ="+(a/b));//a/b外面的括号可以去掉
    System.out.println("a/b= "+(float)a/b);

}
}






a = 13,b 4
a/b =3
a/b= 3.25

发表评论

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