-
What is the output of this program?
public class IndexOf_Example
{
public static void main(String args[])
{
String str="My first love is java.";
System.out.println(str.indexOf('i')+" "+str.indexOf('o')+" "+str.lastIndexOf('i')+" "+str.lastIndexOf('j') );
}
}
-
- 10 14 17 4
- 17 14 10 4
- 4 10 14 17
- 10 4 14 17
- None of these
Correct Option: C
indexof(‘c’) and lastIndexOf(‘j’) are pre defined function which are used to get the index of first and last occurrence of
the character pointed by j in the given array.