public class x {
public float parseFloat(
String s)
{
float f = 0.0f;
try
{
f = Float.valueOf(s).floatValue();
return f;
}
catch(NumberFormatException f)
{
System.out.println("Invalid input" + s);
f1 = Float.NAN;
return f1;
}
finally{ System.out.println("finally"); }
return f;
}
}
This code doesnot compile saying that return statement not reached. My question is why does the compiler gives this error. What is use behind it.
If this code doesnot generate any exception then it can be reached at the last return statement of this code.