2.7 APCSA Vocab: Scanner Class

studied byStudied by 10 people
5.0(1)
learn
LearnA personalized and smart learning plan
exam
Practice TestTake a test on your terms and definitions
spaced repetition
Spaced RepetitionScientifically backed study method
heart puzzle
Matching GameHow quick can you match all your cards?
flashcards
FlashcardsStudy terms and definitions

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
robot