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…
Author
Released
3/21/2018- Downloading Java 9 and choosing an IDE
- Understanding Java basics: data types, strings, arrays, and more
- Controlling flow with functions and loops
- Debugging
- Working with inheritance and interfaces
- Learning lambda
Skill Level Beginner
Duration
Views
-
Introduction
-
Welcome34s
-
-
1. Getting Started
-
Exploring JShell3m 50s
-
Exploring an IDE2m 11s
-
Hello World in Java4m 6s
-
2. Java Basics
-
How do we create code?2m 8s
-
Variables and data types4m 6s
-
Strings7m 12s
-
Arrays8m 48s
-
Exploring documentation3m 1s
-
-
3. Control Flow
-
Decision-making with IF5m 37s
-
Comparing loops5m 18s
-
Debugging with an IDE4m 16s
-
Solution: Dice Roll4m 3s
-
4. Beyond the Basics
-
What is encapsulation?6m 40s
-
Working with inheritance9m 12s
-
Interfaces6m 6s
-
Functional programming1m 4s
-
Learning lambda7m 14s
-
Conclusion
-
Next steps37s
-
- 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.
CancelTake 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.
Share this video
Embed this video
Video: Using the Scanner for input