Error in test case "959440.94f"


  • 0
    S

    I tried to cast String to Double with code below. Java was able to cast "959440.94f" to double but expected answer for this test case is false. Why?

    public class Solution {
    public boolean isNumber(String s) {

         try{
        	 Double d=Double.valueOf(s);
        	 return true;
         }catch(Exception e){
        	 return false;
         }
    	  
    	  
        
    }
    

    }


Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.