String out1 = String.valueOf(100) ; String out2 = String.valueOf(36.27) ; String out3 = String.valueOf(true) ; String out4 = String.valueOf(‘f’) ; 2) 字符串->其他数据类型
int i1 = Integer.parseInt(“111”);
double d=Double.parseDouble(“123.87”); float f=Float. parseFloat(“123.87”)
boolean=Boolean. parseBoolean(“true”) 10. Math类
1) 求两者间较大数:static int max(int a , int b) 2) 求两者间较小数:static int min(int a ,int b) 3) 求绝对值:static int abs(int a) 4) 四舍五入:
5) static int round(float a) 6) static long round(double d)
7) 求n次方:static double pow(double a,double b)
8) 求最大的整数但不大于本身:static double floor(double d) 9) 求最小的整数但不小于本身:static double ceil(double d) 10) 求平方根:static double sqrt(double d) 11) 0-1间的随机数:static double random() 11. 日期处理相关的类
1) java.util.Date用于表示日期和时间 2) Java.util.Calendar
修改时间:
void set(int year,int month,int date) void set(int field,int value) 与Date转换: Date getTime()
void setTime(Date time)
41