java using .indexof to fin a space

122

java using .indexof to fin a space -

class Sample{
public static void main(String[] args) {
    String s = "1110 001";
    int index = -1;
    for(int i = 0; i < s.length(); i++ ){
        if(Character.isWhitespace(s.charAt(i))){
            index = i;
            break;
        }
    }

    System.out.println("Required Index : " + index);
}
}

Comments

Submit
0 Comments