Kathryn shows you how to use the Scanner to get input from the user. By getting input from the user, the program becomes dynamic instead of static and hard coded because the user’s response determines the output of the program.
- [Instructor] In the previous video,…we created some code that used…the string's instance methods.…We set a string input and ran a bunch of…instance methods on it, such as toUpperCase and charAt.…In this video, we will make this program dynamic…by having the user actually input a value…that will be saved in the variable…and ultimately use these instance methods.…To do this, we'll use the scanner class.…The scanner is a part of Java's util package,…and so we'll write an import statement to import…that class so we can use it in our program.…
Up here, we're going to write import java.util.Scanner,…and this is what's going to allow us…to get input from the user.…Now that we have access to the class, we are going to create…an instance of the scanner with its constructor…and save it in a variable.…Going to the top of our main method here, we're going to go…Scanner sc = new Scanner(System.in).…Here, we give System.in as an input to…the scanner constructor so that the scanner knows…where to look for input.…
To get access to what the user inputs, we are going to…
- Downloading Java 9 and choosing an IDE
- Understanding Java basics: data types, strings, arrays, and more
- Controlling flow with functions and loops
- Working with inheritance and interfaces
- Learning lambda
Skill Level Beginner
1. Getting Started
2. Java Basics
3. Control Flow
4. Beyond the Basics
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.