Java Programming Tutorial – 6 – Getting User Input

YouTube Preview Image

Thanks! Share it with your friends!


How to get input from the user


xCraigLV says:

Find your project folder, and then look in binary directory. There should be a .jar file (if you compiled your program) and then just run it.

Or you can find the directory in a terminal and just run it from there.

AaronChapmanDev says:

Then why are you here, and why are you telling us? Go make some money with XNA.

AaronChapmanDev says:

.nextLine() is to execute the code once you’ve pressed enter. In a way it is “bucky.printInTheConsoleWhateITypeAfterIPressEnter()”

AaronChapmanDev says:

You make Java a habit, and use it often. The more you make Java Projects, the more your get accustomed to the different frameworks. It is just like learning about anything else. Repeat things over and over until you’re used to it.

The Zigec says:

There are diffrent types of variables in Java. Such as int, String, boolean, Scanner, Random…. next.Line(); tells the program to conver in this case Scanner variable to String.

Hope that helped you 😉

The Zigec says:

A good way of inporting stuff is just to press Ctrl + Shift + O – For windows, dont know how it works on mac. That basicly imports all stuff that can is needed to be imported in order for the app to work.

JKucera123 says:

It pauses

JKucera123 says:

Why do you need to use the next.Line();

316lga says:

No one asked…

wingsdestiny2 says:

I know various programming language and os such as VB asp, C, C++, Visual Basic, JavaScript, HTML+CSS, PHP, Perl, SQL, AS400, Linux, Fedora, Shell, Bash…

BattleSneeze says:

If anyone here can program with any software, you can join my company

Jangrie123 says:

Easy.. just use another editor. jcreator for example opens a new window if u run a java program!

Frederick Shiafovik says:

that would take you to create a GUI, and that’s kinda of hard to do….. (i’m a beginner in Java also)

AgentJack21 says:

docs dot oracle dot com/javase/7/docs/api/

weterman4320 says:

im sure there is a way, but the bottom is just an example of the program.

Blaine Heiser says:

Thank you so much. 😀 that was rather frustrating. Do you know why that error occurs?

Grant Wesson says:

I Think It Would Be Good if You Expanded On The Meanings… Because for Beginners It Will Be Confusing To Them.

Crush3333 says:

A couple of examples of when that is useful anyone?

The1453cCc says:

You can look at every methods in the library: if you just type in google: “Java library”, then you can see the documentation.

JM1Gamer says:

never mind it wrked now! 🙂

JM1Gamer says:

when i typed in ‘hey now’ it only printed out ‘hey’…..

EinstienJr says:

Hi bucky, I am learning java(From this vids) and I know a bit of C++…..
I have a doubt now.
Using new in c++ is dynamically initilizing pointers and stuff….we can use cin and stuff for normal double or char variable…do we have something in java like that…..??

And your videos are awesome….

HomeopatiaCamelo says:

you have to declare a separate variable that will go in that loop,
That separate variable needs to be assigned to bucky first
int numberLoops;
numberLoops = bucky.SystemInt();

HomeopatiaCamelo says:

you have to declare a separate int variable that will receive whatever the user has input through bucky
int numberLoops;
numberLoops = bucky.SystemInt();

HomeopatiaCamelo says:

Scanner keyboard = new scanner(;
int number;
number = keyboard.Scanner.Int(); notice the Int for integer numbers
String word;
word =; for words

double doubleNumber;
doubleNumber = keyboard.nextDouble();

So, what NewBoston has written refers to inputting a line

HomeopatiaCamelo says:

There are things called books. You must use a good book to learn, otherwise you will never learn. You cannot depend on videos or tutorials.

Niclas Brundell says:

I get “Scanner cannot be resolved to a type” at apples.main(
Anyone know why?

JamesJohnHudson says:

programmers don’t remember all the code. what they don’t know they just look it up on the documentation. i would link you to the documentation but youtube does not let you put links in comments.

ic3cr34m11 says:

@espczay yes. i know you were also thought it might be a fake promise. Listen, my spouse is getting paid monthly for doing some surveys and browsing sites. if you wanna try just try now :

derick1259 says:

Captial S for Scanner.

cambodiakid1 says:

I don’t know any thing about what people are talking about in the Comments.

ps3teb1996 says:

try this

int buckyinput;

buckyinput = bucky.nextInt();

for(int i = 0; i < buckyinput ; i++){whatitdoesblabla}

skateboard3011 says:

How can I use the Scanner for loops? so you can choose how often it loops (you type 5 and then it says  “for(int i = 0; i < 5 ; i++){whatitdoesblabla} " when i write "i < bucky" (eg) it says "bad operand types for bindary operator '<' (...) Can anyone tell me how to solve it??

Stagxhero says:

You want to make a GUI already?unless you meant CMD which is relatively the same you can import a JFrame and use all the methods in that class to make a screen and text box and soforth. look up for more info on how to use a JFrame.

TheSparkleHoof says:

it says the java.util.scanner could not be resolved :O
did i break it?

Kaan Demir Pata says:

Well, that was a bummer. It turns out the jee juno one is the EE version. :S

Kaan Demir Pata says:

ooh, thanks dude. That might be why. I had the jee-juno version :S

DiamondBeforeBros says:

It happened for me then i realized that you must use the one foe EE Developers not any others

RedKurZeGamer says:

maybe its the class name try to change it

Kaan Demir Pata says:

Any ideas what’s wrong with this one guys?

import java.util.Scanner;
class Scanner {
public static void main(String args[]) {
Scanner iron = new Scanner(;

TheZHPMafia says:

it’s extremely case sensitive.. make sure you type exactly “import java.util.Scanner;”

Ryan Marzolf says:

JavaDocs usually is my bet.

noctem9 says:

make sure Scanner is capitalized, and you have a semicolon to end the line.

Olofgame says:

My code looks just like his, but “scanner” have that red type-o thingy under it and i dotn get why, pls help xd

jpell120 says:

i dont have the console tab?

Alex Couch says:

There is an online manual. Its called a Java Wiki on the Eclipse website. Or you can look them all up. Obviously he went to school for this.

Write a comment