JSP各数据类型之间的转换
20:31 | Author: Hui Li 李辉

String -> double:

Double d = Double.valueOf(String s);
Double d = Double.parseDouble(String s);

String -> int:

int i = Integer.parseInt(String s);

int & double -> String:

String s = ""+i;
String s = ""+d;

int -> double:

double d = (double)i;

double -> int:

int i = (int)d;

This entry was posted on 20:31 and is filed under . You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

0 评论: