What is the rationale behind not including such an essential method?
Probably a milion of people have implemented themselves code similar to the one below. Also many others have been forced to write their own number parsing if they couldn't afford exception catching (like importing a lot of data with huge parsing failure ratio).
Shouldn't that be enough reason to include it in the language?
private Float tryParseFloat(String value) {
try {
return Float.parseFloat(value);
} catch (NumberFormatException nfe) {
return null;
}
}
The only possible reason I can think of is that they don't want to make language a garbage. But I don't think adding such a method would.
Note: I believe it's not a duplicate of Java: Good way to encapsulate Integer.parseInt() and similar as there is no discussion about the reasons why this method is missing.