java get index of string code example
Example 1: character at index of string java
String str = "Grepper";
char ch = str.charAt(0);
//ch is assigned the value of G
Example 2: java indexof not found
The java string indexOf() method returns index of given character value or substring. If it is not found, it returns -1. The index counter starts from zero.