Java 基本类型和基本类型的封装

2022-06-28  本文已影响0人  寻找无名的特质

int是基本数据类型,对应的Integer是封装类型,封装类型提供更多的功能和灵活性。基本数据类型对应的封装类如下:
char: Character
byte: Byte
short: Short
Long: Integer
float: Float
double: Double
boolean: Boolean
如果需要将数字格式化,可以使用DecaimalFormat:
NumberFormat format = new DecimalFormat("#.####");
System.out.println(format.format(operation));
java没有直接对应C#的decimal类型。

上一篇下一篇

猜你喜欢

热点阅读