Hi,
Why this code compiles?
public class Conversion
{
public static void main(
String[] args)
{
float d = parseFloat("1");
}
public static float parseFloat(String s)
{
float f = 0.0f; //1
try
{
f = Float.valueOf(s).floatValue(); //2
return f; //3
}
catch (NumberFormatException ex)
{
f= Float.NaN; //4
return f; //5
}
finally
{
return f; //6
}
//return f; //7
}
}
In my opininon the line 6 will never be reached, isn't it?
And the Float.valueOf() doesn't give any other exception that can be ignored by the catch and treated eventually by the finally. Neither Float.floatValue().
I'm quite confused.
Thanks,
..Cristian