Java verwendet .Indexof, um einen Raum zu beenden

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);
}
}
Lazy Lark