Java基础03-类型转换

1.自动转换

  int->double  char->String

  例:double a=10;

2.强制类型转换

  (类型名)表达式

  注意:String不能强制转化为char

 1 public class Test1{
 2     public static void main(String[] args){
 3         int before=20;
 4         double rise=9.8;
 5         int now=before+(int)rise;
 6         System.out.println("现在份额为:"+now);
 7         
 8         
 9     }
10 }
原文地址:https://www.cnblogs.com/shenhainixin/p/9946555.html