Check out example codes for "check if string is decimal java". It will help you in understanding the concepts better.

Code Example 1

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

Code Example 2

try {
    int n = Integer.parseInt(str);
} catch (NumberFormatException e) {
    // str is not a number
}

Learn ReactJs, React Native from akashmittal.com