2.7 APCSA Vocab: Scanner Class

5.0(1)
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
Card Sorting

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.

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

12 Terms

1
New cards

nextInt()

returns the next integer

2
New cards

nextDouble()

returns the next double

3
New cards

nextBoolean()

returns the next boolean

4
New cards

next()

returns the next single string (stops at whitespace)

5
New cards

nextLine()

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

6
New cards

close()

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

7
New cards

void setNums(int, int)

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

8
New cards

void setFirst(int)

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

9
New cards

void setSecond(int)

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

10
New cards

int getSum()

The sum of the 2 numbers is calculated and returned.

11
New cards

void displaySum()

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

12
New cards

Purpose of the Scanner Class

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