Menu
Question Index
...

What will be the output of following program?

public class SubString1 {
    public static void main(String args[]) {
        String cmptr = "it is my computer, my computer works good";
        int count = 0;
        for (int i = 0; i < cmptr.length(); i++) {
            if (cmptr.substring(i, i + 1).equals("m"))
                count++;
        }
        System.out.print(count);
    }
}


3
4
5
Compilation Error or Runtime Error

Doubts

Problems

Topic: Java String substring() method - substring In Java

Read this topic
Take test on this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App