No video

How Do We Get User Input in Java? - Full Tutorial

  Рет қаралды 39,255

Coding with John

Coding with John

Күн бұрын

Complete Java course: codingwithjohn...
All about using the Scanner class in Java to get user keyboard input, with examples for a String, int, and float.
Watch this Java lesson to learn how to use the built-in Scanner class to retrieve input from the user!
Learn or improve your Java programming by watching it being coded live in tutorials!
Hey, I'm John! I'm a Lead Java Software Engineer who has been in the industry for over a decade, and I love teaching what I know.
Tell me what else you want to see!
Links to any stuff in this description are affiliate links, so if you buy a product through those links I may earn a small commission.
📕 THE best book to learn Java, Effective Java by Joshua Bloch
amzn.to/36AfdUu
📕 One of my favorite programming books, Clean Code by Robert Martin
amzn.to/3GTPVhf
🎧 Or get the audio version of Clean Code for FREE here with an Audible free trial
www.audibletria...
🖥️Standing desk brand I use for recording (get a code for $30 off through this link!)
bit.ly/3QPNGko
📹Phone I use for recording:
amzn.to/3HepYJu
🎙️Microphone I use (classy, I know):
amzn.to/3AYGdbz
Donate with PayPal (Thank you so much!)
www.paypal.com...
☕Complete Java course:
codingwithjohn...
codingwithjohn...

Пікірлер: 58
@thaimilamonegabolander8338
@thaimilamonegabolander8338 11 ай бұрын
Thanx so much John! I'm on my third week for Java dev. Yesterday I cried in class, and yelled; I just don't understand anything! Today I'm back up on the horse. My teacher guided me to your chanel. XOXO thai
@ruantristancarlinsky3851
@ruantristancarlinsky3851 2 жыл бұрын
You are so amazing, Please continue making more videos on Java. Will be greatly appreciated!
@AlexKelly-mk8py
@AlexKelly-mk8py Күн бұрын
Ty so much this helped me print some basic code.
@raphaelferrazza4412
@raphaelferrazza4412 2 жыл бұрын
Im surprised so many people make videos or go on forums despite how wrong they are most of the time! its really amazing
@aliyyah.u
@aliyyah.u Жыл бұрын
Super helpful and easy to understand!
@kristinaz7046
@kristinaz7046 2 жыл бұрын
Cheese sanwidch is not garbage. Video is very helpful!
@Arfifias
@Arfifias Жыл бұрын
I would like smaller and easier tutorials like constructor tutorial you made that was pretty good
@etipeti555
@etipeti555 5 ай бұрын
In chapter 8 I was taught something called casting (not working with the scanner class). Are both what I mentioned and what you tought us equaly valid or is there a difference?
@tushartomar3586
@tushartomar3586 2 жыл бұрын
buddy you're doing a great job , i really want to thankyou for this, could you plz make a video about oops but in advance way, but each of the four concept should be explained in the separate video
@theconsul8452
@theconsul8452 2 жыл бұрын
At 6:36 , how did you delete the whole line so quickly without selecting the characters ? What is that keyboard shortcut ?
@CodingWithJohn
@CodingWithJohn 2 жыл бұрын
Control + D, works in many programs. One of my most used shortcuts for sure!
@ibnearabi3640
@ibnearabi3640 2 жыл бұрын
Great explanation. Thank you.
@higiniofuentes2551
@higiniofuentes2551 6 ай бұрын
Thank you for this very useful video!
@ensarthewicked
@ensarthewicked 5 ай бұрын
love you john, I really do
@thariqdeyis140
@thariqdeyis140 11 ай бұрын
How to make the scanner inputs are beside the question??
@mithunbiswas5307
@mithunbiswas5307 2 жыл бұрын
Great explanation, thanks
@Nelfa183
@Nelfa183 Жыл бұрын
Wao you made it so simple . Thanks 🙌
@Ahmadzai-15
@Ahmadzai-15 Жыл бұрын
Great method how to teach Respect from Afghanistan 🇦🇫…
@szaronaangel7725
@szaronaangel7725 2 жыл бұрын
It's a veeery good tutorial, thank you!
@dypsking3414
@dypsking3414 2 жыл бұрын
Love all your videos... You're truly awesome 👍💪 Please could you do a video on the different types of ways to get user inputs? Be keeping an eye out for this ✊✊
@saarza9991
@saarza9991 6 ай бұрын
Scanner and BufferedReader
@vic17.
@vic17. Жыл бұрын
i have a question at around 11:05, I saw you assigned floatAge the value inside of the try block, but declared it outside of it. Is this necessary, or could you declare floatAge and initialize both inside of the try block?
@piikayy7511
@piikayy7511 Жыл бұрын
If you declare and initialize the floatAge variable inside of the try block you will only be able to use it inside(!) of the try block, as it only exists within that block. So if you are looking to, for example print out the value of floatAge later on (like John did in the video), you will have to declare and initialize it outside of the try block.
@vic17.
@vic17. Жыл бұрын
@@piikayy7511 oh ok that makes sense thank you
@johnnyjohn6645
@johnnyjohn6645 2 жыл бұрын
thanks a lot John !
@vaibhavhanegave256
@vaibhavhanegave256 Жыл бұрын
nice and helpfull thank you bro.
@harshvaviya1467
@harshvaviya1467 Ай бұрын
great video
@unbelievable699
@unbelievable699 3 жыл бұрын
thaanks alot
@briankwala7923
@briankwala7923 Жыл бұрын
great job sir!
@anyahayes3601
@anyahayes3601 2 жыл бұрын
Can you explain why you can’t reopen a Scanner after you call close?
@SPXCVIII
@SPXCVIII 2 жыл бұрын
Thank You
@javidaghayarli8252
@javidaghayarli8252 2 жыл бұрын
Thanks boss 👍
@chandulasamarasinghe3088
@chandulasamarasinghe3088 Жыл бұрын
love your videos
@jeremyunger9806
@jeremyunger9806 7 ай бұрын
So we're just ignoring his shoe size? (Great video)
@jakesegal
@jakesegal 2 жыл бұрын
Johns the best!
@Pacvalham
@Pacvalham 2 жыл бұрын
I can't make a cheese sandwich into a float, but I can make ice cream into a float by pouring soda on it.
@riskofrankin6171
@riskofrankin6171 Жыл бұрын
Put the sandwich in some soda
@ntphiep
@ntphiep 2 жыл бұрын
Great video , but can I have a question ? Why my scanner nextFloat read float from keyboard with comma instead of dot ? , can you help me . Thanks
@Scofield9975
@Scofield9975 2 жыл бұрын
Your scanner is high
@fandusmercius723
@fandusmercius723 2 жыл бұрын
depends on your windows keyboard language probably
@mhdmk8245
@mhdmk8245 2 жыл бұрын
Ty sir
@kebroonabebayehu2559
@kebroonabebayehu2559 2 жыл бұрын
You're awesome!
@inoobbeyt1031
@inoobbeyt1031 Жыл бұрын
What happened in while condition i didn't get
@Mrexecexec
@Mrexecexec 2 жыл бұрын
Hi John. I have a strange issue. I expect code below to allow me to enter 3 string elements from keyboard but unfortunately after entering two strings, immediately I see the output of myStrings array which looks odd: [FirstString, ,SecondString]. There is an empty element between myStrings[0] and myStrings[2]? Why? It is expecting that each scanner.nextLine() will consume the new line including ; but the situation is not as such? import java.util.Arrays; import java.util.Scanner; public class Main { private static Scanner scanner = new Scanner(System.in); public static void main(String[] args) { String[] myStrings = getStrings(3); System.out.println(Arrays.toString(myStrings)); } public static String[] getStrings(int number){ System.out.println("Enter "+number+" strings "); String[] values = new String[number]; for (int i=0;i< values.length;i++){ values[i]=scanner.nextLine(); } return values; } }
@Mrexecexec
@Mrexecexec 2 жыл бұрын
My real output is "C:\Program Files\Amazon Corretto\jdk11.0.15_9\bin\java.exe" "-javaagent:C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2022.1.1\lib\idea_rt.jar=49409:C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2022.1.1\bin" -Dfile.encoding=UTF-8 -classpath C:\Users\ARCHITECT\IdeaProjects\ArrayVsArrayList\out\production\ArrayVsArrayList Main Enter 3 strings. First Second [First, , Second] Process finished with exit code 0
@Mrexecexec
@Mrexecexec 2 жыл бұрын
Another code peace which is odd too. The problem is with scanner.nextLine() but why? import java.util.Arrays; import java.util.Scanner; public class Main { private static Scanner scanner = new Scanner(System.in); public static void main(String[] args) { String[] myStrings = new String[3]; myStrings[0]=scanner.nextLine(); myStrings[1]=scanner.nextLine(); myStrings[2]=scanner.nextLine(); System.out.println("End entering. But problem is still there"); System.out.println(Arrays.asList(myStrings)); } }
@Pacvalham
@Pacvalham 2 жыл бұрын
I prefer a bang instead of "== false".
@ndk8111
@ndk8111 2 жыл бұрын
13:38. Is this bad practise to evaluate booleans as booleanName == false How about (!booleanName) in your example.
@bloomin1819
@bloomin1819 2 жыл бұрын
With that shoe size, you ever play any basketball??
@CodingWithJohn
@CodingWithJohn 2 жыл бұрын
Not since 8th grade or so 🫤
@murtajiz545
@murtajiz545 2 жыл бұрын
Thanks for the video mate but are we gonna ignore this man having a size 14 foot? 💀
@hackcracker7691
@hackcracker7691 2 жыл бұрын
Jhonny sins 😂😂 brother im joking
@eternalflames911
@eternalflames911 Жыл бұрын
But i dont wanna be a good boy scout...im a girl
@kIllera911
@kIllera911 2 жыл бұрын
Java is really verbose
Map and HashMap in Java - Full Tutorial
10:10
Coding with John
Рет қаралды 567 М.
INPUT-OUTPUT FUNCTIONS(SCANNER CLASS) - JAVA PROGRAMMING
29:11
Sundeep Saradhi Kanthety
Рет қаралды 162 М.
大家都拉出了什么#小丑 #shorts
00:35
好人小丑
Рет қаралды 77 МЛН
КТО ЛЮБИТ ГРИБЫ?? #shorts
00:24
Паша Осадчий
Рет қаралды 4,3 МЛН
Unveiling my winning secret to defeating Maxim!😎| Free Fire Official
00:14
Garena Free Fire Global
Рет қаралды 16 МЛН
SPONGEBOB POWER-UPS IN BRAWL STARS!!!
08:35
Brawl Stars
Рет қаралды 24 МЛН
Vectors in Java: The 1 Situation You Might Want To Use Them
16:13
Coding with John
Рет қаралды 80 М.
Checked vs. Unchecked Exceptions in Java Tutorial - What's The Difference?
10:14
How to get String Input from a User in Java #12
6:22
Alex Lee
Рет қаралды 264 М.
Learn JSON in 10 Minutes
12:00
Web Dev Simplified
Рет қаралды 3,2 МЛН
Learn Java in 14 Minutes (seriously)
14:00
Alex Lee
Рет қаралды 4,7 МЛН
.equals() vs. == in Java - The Real Difference
8:48
Coding with John
Рет қаралды 186 М.
Learn Any Programming Language In 3 Hours!
22:37
Code With Huw
Рет қаралды 360 М.
LinkedList vs ArrayList in Java Tutorial - Which Should You Use?
11:43
Coding with John
Рет қаралды 588 М.
#83 User Input using BufferedReader and Scanner in Java
11:48
大家都拉出了什么#小丑 #shorts
00:35
好人小丑
Рет қаралды 77 МЛН