how to check if a number is decimal in java code example
Example 1: how to check for a decimal point in java
d % 1 == 0
//THIS CHECKS IF VARIABLE D IS A WHOLE NUMBER
Example 2: 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");