How to find the index of the last space in string with Java

1 Answer

0 votes
public class MyClass {
    public static void main(String args[]) {
        String s = "java c c++ python c# php";
        char ch = ' ';

        int last_index = s.lastIndexOf(ch);

        System.out.println(last_index);
    }
}





/*
run:

20

*/

 



answered Feb 16, 2022 by avibootz

Related questions

1 answer 87 views
1 answer 92 views
1 answer 89 views
1 answer 79 views
1 answer 84 views
...