Scanner class

Pataasin ang iyong marka sa homework at exams ngayon gamit ang Quizwiz!

nextBoolean()

Reads a boolean value from the user

nextByte()

Reads a byte value from the user

nextDouble()

Reads a double value from the user Scanner myObj = new Scanner(System.in); // Numerical input int age = double salary = myObj.nextDouble();

nextFloat()

Reads a float value from the user

nextLong()

Reads a long value from the user

nextShort()

Reads a short value from the user

nextLine()

Scanner myObj = new Scanner(System.in); Reads a String value from the user // String input String name = myObj.nextLine();

nextInt()

Scanner myObj = new Scanner(System.in); Reads a int value from the user // Numerical input int age = myObj.nextInt();

How do you use Scanner?

Scanner myObj = new Scanner(System.in); create an object of the class and use any of the available methods found in the Scanner class documentation.

What does the Scanner class do?

The Scanner class is used to get user input, and it is found in the java.util package.


Kaugnay na mga set ng pag-aaral

Chapter 9 Life insurance license

View Set

Chapter 11 Quiz: The Fat-Soluble Vitamins: A, D, E, and K

View Set

PN NCLEX 6th Edition- Mental Health

View Set

Module 8 - Program and App Use and Development

View Set

BIO 111 General Biology Chapter 6 (Mastering Biology)

View Set

SCIENCE - 1.4 Molecules: (EVERYTHING)

View Set