Java examples for java.lang:String Index
What is the index Of a char inside a string
public class Main { public static void main(String[] argv) { String str = "java2s.com"; char searchChar = 'a'; System.out.println(indexOf(str, searchChar)); }// ww w . j a v a2 s. c om public static int indexOf(String str, char searchChar) { if (isEmpty(str)) { return -1; } return str.indexOf(searchChar); } public static boolean isEmpty(String str) { return str == null || str.length() == 0; } }