Scanner
practice
The next couple problems are about a file called readme.txt
that has the following contents:
6.7 This file has several input LINES! 10 20
What would be the output from the following code, as it would appear on the console?
Scanner input = new Scanner(new File("readme.txt")); System.out.println(input.next()); // 6.7 System.out.println(input.next()); // This System.out.println(input.next()); // file
Scanner
practice
Input file: readme.txt
6.7 This file has several input LINES! 10 20
What would be the output for the following code? If there would be an error, write error .
Scanner input = new Scanner(new File("readme.txt")); System.out.println(input.nextDouble()); // 6.7 System.out.println(input.nextDouble()); // error
Scanner
practice
Input file: readme.txt
6.7 This file has several input LINES! 10 20
What would be the output for the following code? If there would be an error, write error .
Scanner input = new Scanner(new File("readme.txt"));
while (!input.hasNextInt()) {
input.next();
}
System.out.println(input.nextInt()); // 10