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");