2.7 APCSA Vocab: Scanner Class

studied byStudied by 8 people
5.0(1)
Get a hint
Hint

nextInt()

1 / 11

flashcard set

Earn XP

Description and Tags

Existing classes and class libraries can be utilized as appropriate to create objects. One example of an existing class in Java is the Scanner class. The Scanner class is used to capture user input to use in program code. The Scanner class library is part of the java.util package and must be imported in order to be used.

12 Terms

1

nextInt()

returns the next integer

New cards
2

nextDouble()

returns the next double

New cards
3

nextBoolean()

returns the next boolean

New cards
4

next()

returns the next single string (stops at whitespace)

New cards
5

nextLine()

returns the next line as a string (stops at new line)

New cards
6

close()

void method that tells the program you are no  longer using the scanner

New cards
7

void setNums(int, int)

provide 2 integers as parameters.  The 2 numbers in Adder are set to those values.

New cards
8

void setFirst(int)

provide 1 integer as a parameter.  The first number in Adder is set to that value.

New cards
9

void setSecond(int)

provide 1 integer as a parameter.  The second number in Adder is set to that value.

New cards
10

int getSum()

The sum of the 2 numbers is calculated and returned.

New cards
11

void displaySum()

This method has no parameters and adds the two instance variables together and displays the sum.

New cards
12

Purpose of the Scanner Class

The Scanner class is used to capture user input to use in program code.

New cards

Explore top notes

note Note
studied byStudied by 4 people
... ago
4.5(2)
note Note
studied byStudied by 18 people
... ago
5.0(1)
note Note
studied byStudied by 4 people
... ago
5.0(1)
note Note
studied byStudied by 7 people
... ago
5.0(1)
note Note
studied byStudied by 40 people
... ago
5.0(1)
note Note
studied byStudied by 19 people
... ago
5.0(1)

Explore top flashcards

flashcards Flashcard (69)
studied byStudied by 1 person
... ago
5.0(1)
flashcards Flashcard (87)
studied byStudied by 3 people
... ago
5.0(1)
flashcards Flashcard (30)
studied byStudied by 3 people
... ago
5.0(1)
flashcards Flashcard (107)
studied byStudied by 56 people
... ago
5.0(3)
flashcards Flashcard (23)
studied byStudied by 22 people
... ago
5.0(1)
flashcards Flashcard (64)
studied byStudied by 10 people
... ago
5.0(1)
flashcards Flashcard (30)
studied byStudied by 9 people
... ago
5.0(1)
flashcards Flashcard (45)
studied byStudied by 225 people
... ago
5.0(11)
robot