KnowledgeBoat Logo

Computer Applications

Write a line of code that:

i. Creates a Scanner object named scanner to be used for taking keyboard input.

ii. Uses the object scanner to read a word from the keyboard and store it in the String variable named stg.

Input in Java

10 Likes

Answer

i. Creates a Scanner object named scanner to be used for taking keyboard input.

Scanner scanner = new Scanner(System.in);

ii. Uses the object scanner to read a word from the keyboard and store it in the String variable named stg.

String stg = scanner.next();

Answered By

5 Likes


Related Questions