Home / Questions / What will the following code output: String s = "malayalam"; System.out.println(s.indexOf('m')); System.out.println(s.lastIndexOf('m'));
Explanatory Question

What will the following code output:

String s = "malayalam";
System.out.println(s.indexOf('m'));
System.out.println(s.lastIndexOf('m'));

👁 69 Views
📘 Detailed Answer
🕒 Easy to Read
Read the answer carefully and go through the related questions on the right side to improve your understanding of this topic.

Answer with Explanation

Output


0
8

Explanation



The first m appears at index 0 and the last m appears at index 8.