I have sentences starting with
- ccccccccddkskdjskjdksjdfksjfkjs sjfsjfksjjs
I want to see if the starting of the line I read is with a number and . if yes I want to read the rest of the line.
How can I do that ?
I taught of reading the line to a
string str.
str[0] and str [1].
str[1]= .
x= Character.isDigit(string.charAt(0));
if(x) { if (string.charAt(1)=='.')
{ print ...I get a Exception
is there a easy way that I can check if str[0] is a number ..right now I am checking manually if it is 1 (or) 2...like that?
Exception in thread "main" java.lang.StringIndexOutOfBoundsException: String index out of range: 1 at java.lang.String.charAt(Unknown Source)