// Program to explain the following String function :
// int indexOf(int ch)
// int indexOf( String str )class MindexOf
{
public static void main(String args[ ])
{
String s1 = "Java Programming Examples Java Programming Examples.";
System.out.println(" Index of " + 'P' + " = " + s1.indexOf('P'));
System.out.println(" Index of " + 'x' + " = " + s1.indexOf('x'));
System.out.println(" Index of " + "Examples" + " = " + s1.indexOf("Examples"));
System.out.println(" Index of " + "JAVA" + " = " + s1.indexOf("JAVA"));
}
}
Output:Index of P = 5
Index of x = 18
Index of Examples = 17
Index of JAVA = -1