26.4k views
0 votes
What is the output of this program?

class output
{
public static void main(String args[])
{ String a = "hello i love java"; System.out.println(a.indexOf('i')+" "+a.indexOf('o')+" "+a.lastIndexOf('i')+" "+a.lastIndexOf('o'));
}

1 Answer

6 votes

Answer:

6 +4 + 6 +4

Step-by-step explanation:

It will start from index 0 and wherever you find the character inside the indexOf methods then you will note it down.

User Paolo Forgia
by
5.4k points