Syntax Flashcards
1
Q
How do you import the scanner class?
A
import java.util.Scanner;
2
Q
How do you create a new scanner class?
A
Scanner input = new Scanner(system.in);
Where input is the name of the class.
3
Q
How do you use the scanner class you created?
A
int length;
length = input.nextInt();
Where input is the name of the scanner class.
4
Q
How to let the user input a string?
A
String hello;
hello = input.nextLine();
Where input is the name of the scanner class.
5
Q
How do you make the Scanner class read a character?
A
char initial;
initial = input.nextLine().charAt(0);
6
Q
This statement is used to indicate that the case statement is finished.
A
break