Given:
3. import java.util.*; 4. public class Main { 5. public static void main(String[] args) { 6. String input = "1 2 a 3 45 6"; 7. Scanner sc = new Scanner(input); 8. int x = 0; 9. do {//from www . jav a 2 s . c o m 10. x = sc.nextInt(); 11. System.out.print(x + " "); 12. } while (x!=0); 13. } 14. }
What is the result?
F is correct.
The nextXxx()
methods are typically invoked after a call to a hasNextXxx()
, which determines whether the next token is of the correct type.