I expected the output of the following code to be 5... Cant explain what I am doing wrong.. Code compiles but an exception is thrown an runtime..Is it perhaps the use of delimiter?
import java.util.*;
public class Test {
public static void main(String[] args) {
String csv = "Sue,5,true,3";
Scanner scanner = new Scanner(csv);
scanner.useDelimiter(",");
int agr = scanner.nextInt(); //Throws java.util.InputMismatchException
}
}
Thanks for any help.