I just added the main method with the class name parstIt in order to print. The explanation given is that the 'return' statement in finally block is unreachable, otherwise it will print options 1,2,3(please see the options in the JQPlus
applet).
I find that if you comment out any of the 'return' statements at 'try', 'catch' or 'finally' blocks, it will print only "finally". That does not match with JQPlus - I need further clarifications pls.....
Albert
//Question ID :957638871199
//Following is a supposedly roboust method to parse an input for a float....
class parseIt
{
public static void main(
String [] parse)
{
new parseIt().parseFloat("0.1");
}
public float parseFloat(String s)
{
float f = 0.0f;
try
{
f = Float.valueOf(s).floatValue();
return f ;
}
catch(NumberFormatException nfe)
{
System.out.println("Invalid input " + s);
f = Float.NaN ;
//return f;
}
finally { System.out.println("finally"); }
return f ;
}
}