try {
InputStreamReader isr = new InputStreamReader(System.in);
BufferedReader br = new BufferedReader(isr);
String s = br.readLine();
DecimalFormat df = new DecimalFormat();
Number n = df.parse(s);
double d = n.doubleValue();
} catch (IOException e) {
e.printStackTree();
} catch (ParseException e) {
e.printStackTree();
}
或
try {
InputStreamReader isr = new InputStreamReader(System.in);
BufferedReader br = new BufferedReader(isr);
String s = br.readLine();
double d = Double.parseDouble(s);
} catch (IOException e) {
e.printStackTree();
} catch (ParseException e) {
e.printStackTree();
}
他們說,最簡單的方法:) –
也容易:) – erimerturk