Answers for "how to check if string can be parsed to int java"

1

java check if able to parse int

public static boolean isParsable(String input) {
    try {
        Integer.parseInt(input);
        return true;
    } catch (final NumberFormatException e) {
        return false;
    }
}
Posted by: Guest on January-26-2021
0

check if string is decimal java

Scanner in = new Scanner(System.in);
		
		String ip1 = in.nextLine();
		
		if( ip1.matches("^\d+\.\d+") ) 
			System.out.println(ip1+"----is a decimal number");
		else
			System.out.println(ip1+"----is a not decimal number");
Posted by: Guest on May-11-2020

Code answers related to "how to check if string can be parsed to int java"

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language