Code: Select all
public static float parseFloat1(String s1) {
try {
return Float.parseFloat(s1);
} catch (NumberFormatException e) {
return 0.0f;
} catch (IllegalArgumentException e) {
return Float.NaN;
}
}
Indeed, there is a difference between returning(a float 0.0f) and actually printing(a float 0.0).
I am interested in your take on this matter.