+indexof(ch:char)

Return type int.
Returns the index of the first occurrence of ch in the string. Returns-1 if not matched.

import java.lang.String;
class indexof{
                        public static void main(String[] args){
                         String str="Welcome to java";
                        int i="welcome".indexOf('l');
                       System.out.println("Index of l in \" "+str+"\"  is : "+i);
                     }
}

Output :    Index of l in "Welcome to java is : 2

Popular posts from this blog

Shutdown Pc

Ellipse using OpenGl

String Comparisons