区别就是接受的参数不同,返回更不同,
1、parseInt是把String转换成int,注意是基本类型,valueOf()还可以接受int类型参数,返回的封装类Integer!
关于过时的问题,直接用DateFormat类的相应方法parse完成!比如:
int pi = Integer.parseInt("3.14");
int r = Integer.valueOf("2.0").intValue();
2、parseDouble是把String转换成double,注意是基本类型,valueOf()还可以接受double类型参数,返回的封装类Double!
double pi = Double.parseDouble("3.14");
double r = Double.valueOf("2.0").doubleValue();
Double.valueOf() 返回一个 double的对象
Double.parse()返回一个double值
parseDouble(String s)
Returns a new double initialized to the value represented by the specified String, as performed by the valueOf method of class Double.
valueOf(String s)
Returns a Double object holding the double value represented by the argument string s.
所以一个返回的是double类型数据,一个返回的是Double类型的对象!!
1、parseInt是把String转换成int,注意是基本类型,valueOf()还可以接受int类型参数,返回的封装类Integer!
关于过时的问题,直接用DateFormat类的相应方法parse完成!比如:
int pi = Integer.parseInt("3.14");
int r = Integer.valueOf("2.0").intValue();
2、parseDouble是把String转换成double,注意是基本类型,valueOf()还可以接受double类型参数,返回的封装类Double!
double pi = Double.parseDouble("3.14");
double r = Double.valueOf("2.0").doubleValue();
Double.valueOf() 返回一个 double的对象
Double.parse()返回一个double值
parseDouble(String s)
Returns a new double initialized to the value represented by the specified String, as performed by the valueOf method of class Double.
valueOf(String s)
Returns a Double object holding the double value represented by the argument string s.
所以一个返回的是double类型数据,一个返回的是Double类型的对象!!