From the course: Java 11+ Essential Training
Unlock the full course today
Join today to access over 22,600 courses taught by industry experts or purchase this course individually.
Get string values from user input - Java Tutorial
From the course: Java 11+ Essential Training
Get string values from user input
- [Instructor] In a command line application you can get string based input using a class named Scanner. The first step is to create an instance of that class. In this beginning application I'll create a variable that I'll name scanner, and I'll instantiate it with new scanner. And then I need to pass in a location from which the data is going to come. And I'll pass in the expression, system dot in. Now notice I'm getting a warning that this symbol scanner isn't recognized, so I'll place the cursor inside the class name and then hold down the Alt or option key and press enter or return, and I'll choose Import Class. And that will create the import statement that's required at the top of the file. Now I can receive input. Before I receive the input I want to tell the user what I'm expecting. So I'm going to use system dot out but this time instead of println I'll just use a method named print and that'll output a string…
Contents
-
-
-
-
-
-
(Locked)
Declare and initialize string values3m 55s
-
(Locked)
Build a string from multiple values4m
-
(Locked)
Clone the exercise files from GitHub3m 57s
-
(Locked)
Convert primitive values to strings3m 29s
-
(Locked)
Format numeric values as strings5m 55s
-
(Locked)
Interpolate strings with placeholders3m 7s
-
(Locked)
Compare string values4m 27s
-
(Locked)
Parse string values2m 36s
-
(Locked)
Get string values from user input3m 34s
-
(Locked)
Challenge: A simple calculator1m 9s
-
(Locked)
Solution: A simple calculator1m 18s
-
(Locked)
-
-
-
-
-
-