Menu
Question Index
...

What will be the output of the following program?

import java.util.regex.*;
public class Function {
    public static void main(String[] args) {
        Pattern p = Pattern.compile("pqp");
        Matcher m = p.matcher("pqpqppqpqpppqqpqppqpqppppqp");
        boolean b = false;
        while (b = m.find()) {
            System.out.print(m.start() + " ");
        }
    }
}


0 3 6 9 16 19 22 27
0 3 6 15 18 25
0 5 14 17 24
Some other output
Compilation Error or Runtime Error

Doubts

Problems

Topic: Java Regular Expression

Read this topic
Take test on this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App