public class Test1 {
/**
* @param args
*/
static Integer one;
static Float two;
static Double three;
public static void main(String[] args) {
String[] arr = new String[] { "1", "1.1", "11.11","1.1111111111","23","11111.1","3343423423423423424234234.2342352323452345234523455235" };
for (int i = 0; i < arr.length; i++) {
try {
one=Integer.valueOf(arr[i]);
} catch (NumberFormatException e) {
two=Float.valueOf(arr[i]);
}finally{
three=Double.valueOf(arr[i]);
}
System.out.println("整数"+one+"单浮点"+two+"双精度"+three);
}
}
}
单双我就判断不出来了 学习程度有限 |