java基本数据类型转换

it2023-09-27  77

package com.ff.javabase.day2; public class DataType { public static void main(String[] args) { //默认转换(小容量转到大容量) int a1 = 180; int b = 139; long a2 = a1; float f1 = a2; System.out.println(f1); //参与运算 float f2 = a1 + b; System.out.println(f2); //强制转换 long l1 = 99999; int l2 = (int)l1; System.out.println(l2); //溢出 int b1 = 258; byte b2 = (byte)b1; System.out.println(b2); //精度降低 float t1 = 10.5F; long t2 = (long)t1; System.out.println(t2); } }
最新回复(0)