dkim18
asked on
public static double parseDouble(String s)
For the following method, what does this return when empty string passed?
public static double parseDouble(String s)
public static double parseDouble(String s)
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Just put the parseDouble () call in a try block and put a catch block for the NumberFormatException.
try
{
double d = Double.parseDouble ( "anything" ) ;
}
catch ( NumberFormatException e )
{
// if it enters here - the format was incorrect
}
{
double d = Double.parseDouble ( "anything" ) ;
}
catch ( NumberFormatException e )
{
// if it enters here - the format was incorrect
}
public class Program
{
public static void main(String[] argv)
{
double answer = Double.parseDouble("");
System.out.println("It produced:" + answer);
}
}