首先基本类型:byte、short、int、long、float、double相应的类型为:Byte、Short Integer Long Float Double类型
类的好处:
1、可以用类中的很多方法、类型转行、比较、相等类型、与字符串之间的转化。
2、可以用一些常量。类型的最大值最小值 Byte.MAX_VALUE
3、当函数的参数需要为对象的时候,基本类型可以转化为类,完成参数传递。
以上物种类型都有number类型继承而来,number的通用函数有:
1、类型转换、
byte byteValue()
short shortValue()
int intValue()
long longValue()
float floatValue()
double doubleValue()
比较函数: int compareTo();
等于类型 boolean了 equals(object);
interger类型独有的函数类型,其他类型可以类似:
static Integer decode(String s)
static int parseInt(String s)
static Integer valueOf(String s)
static Integer valueOf(String s,int radix)
注意类型后面几个函数比较重要,完成字符串与类型的转换。
注意:
常量正数自动转化为int类型、小数正数转化为double类型
byte(short)->int->float->double 变量类型自动转化顺序
注意:byte与short类型不会自动转化,这个在函数重载中会有影响
字符串的格式输出函数:format/printf函数,