Menu
Question Index
...

What will be output of the following program?

import java.util.*;
public class ScannerExample {
    public static void main(String arg[]) {
        String i = "7,  6,  5,    4";
        Scanner sc = new Scanner(i);
        sc.useDelimiter(", *");
        while (sc.hasNext()) {
            if (sc.hasNextInt())
                System.out.print(sc.nextInt() + " ~ ");
        }
    }
}


7 ~ 6 ~ 5 ~ 4 ~
7 ~  6 ~  5 ~   4 ~
Compilaton Error
Runtime Error

Doubts

Problems

Topic: Java Scanner Class Methods With Examples

Read this topic
Take test on this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App