package com.chongrui.test;
public class TypeConvertion {
public static void main(String[] args) {
// TODO Auto-generated method stub
int intNum = 3;
float floatNum = 1.5F;
floatNum /= intNum;
System.out.println("1.5F除以3的商是"+floatNum);
System.out.println(" ");
double numX = 4.8;
double numY = 1.3;
int numZ = (int)numX+(int)numY;
System.out.println("numX转成int型:"+(int)numX);
System.out.println("4.88和78.83转换成int型相加的和是:"+numZ);
char charVar = 'T';
int intVar = (int)charVar;
System.out.println("将字符T转换成Int型"+intVar);//不能理解
int num1 = 34;
double num2 = (double)num1/3;//(把34转成三分之一)
System.out.println("把34的三分之一转成double型是"+num2);
}
}
1.5F除以3的商是0.5
numX转成int型:4
4.88和78.83转换成int型相加的和是:5
将字符T转换成Int型84
把34的三分之一转成double型是11.333333333333334