Menu
Question Index
...

What will be the output of following program?

public class Usingif {
    public static void main(String args[]) {
        String email = "bhargavi.t@gmail.com";
        String mail = ".com";
        int x = email.indexOf(mail, 18);
        if (x == -1) {
            System.out.println("Invalid mail id");
        } else {
            System.out.println("Valid mail id");
        }
    }
}


Valid mail id
Invalid mail id
Compilation Error
Runtime Error

Doubts

Problems

Topic: Java Searching Strings - Java indexOf, lastIndexOf Methods

Read this topic
Take test on this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App