

CODE IS HERE:
Best Java Book :
I continue my Java Video Tutorial. I show you how to import class libraries, except user input, check for valid input, catch errors in input, a bunch of math functions and more.
source
CODE IS HERE:
Best Java Book :
I continue my Java Video Tutorial. I show you how to import class libraries, except user input, check for valid input, catch errors in input, a bunch of math functions and more.
source
Up
Are there any Anki decks made for this series?
I want to force the user to type an integer in case of text input but it just stops. I have been stuck in this for 3 days trying to figure out how to go back and make the user retype. I just learnt that there is no goto so I have no idea what to do. Help would be appreciated.
Hey Derek: Just found your videos on Java… (and so much more). Great work! Also checked out your website (newthinktank.com). Very nice!
I do have a couple of questions though: (1) I was trying to get some of the code samples that you came up with (very well coded, BTW), and had some trouble downloading these samples. Do you have any links to downloadable text files of these code snippets? IYO, what is the easiest way to download them (and actually see them running)?
And (2) you jump right in with using Eclipse. Do you have any videos on how to start using Eclipse? I would be switching from a quite different type of IDE. If not, what do you recommend for coming up to speed in using Eclipse?
Nice nice job, nonetheless!
🙂
'…and we're going to type new to get a new scanner object because that's how we get a new scanner object.' Derek says soberly… 'we're always going to this'
paraphrased hilarious
I am a long time Java guy. spent a few years in Kotlin, refresher…
Great tutor here…Kudos Derek
Just wanted to say thanks, Derek. I've been learning Java for about two weeks, have followed some tutorials and I've written a very primitive money tracking app from scratch but I felt like I'd hit a wall with what to do next. I had been on Codecademy and CodeGym and although they're purported to be the best thing since sliced bread, I felt like I was stuck. Your videos are concise and easy to follow and I've learned so much from them already. So again, thank you!
awesome but you sound like brian regan, which makes it better
'var.hasNextInt()' has already taken the user input, then how did value 13 reached 'numberEntered' variable (I mean, you need to give second input here?)
Hi, I have a really big question: if I wrote in the console from a class, can I read that output from an other class? I found some stackoverflow posts, but not a single one was good for me. I would use this "thing" in a server-client project. Thanks for the answer, have a great day!
I belive this is my first ever comment on youtube and i just want to say you're awsome, hope you're still making videos
Someone help me with this
Scanner userInput = new Scanner(System.in);
If( userInput.hasNextInt )
{
int x = userInput.nextInt();
System.out.println(x);
} // Just explain if we add another variable inside if statment example b = nextInt(); than it will require two numbers but when we have x it doesnt require another number
can you help me use a text file to get arguments for a method
You are just a boss.Keep going
Derek, first off your teaching is working wonders. I've learned more from you in the past hour from your videos than i have reading text books for a year, thank you for all you do. Also do you think you could do a video over how you create your anki flash cards for programming and programming concepts?? Or maybe even make those decks available for us to download?
could u have that scanner object inside the main method or is it supposed to be outside the main method?
python vs java:
java calculator:
import java.util.Scanner;
public class FirstClass{
static Scanner userInput = new Scanner(System.in);
public static void main (String args[]){
int z;
System.out.println("This is a basic calculator");
System.out.println("Enter Your First Number:");
if (userInput.hasNextInt()){
int x = userInput.nextInt();
System.out.println("You entered " +x);
System.out.println("Enter your next number:");
if (userInput.hasNextInt()){
int y = userInput.nextInt();
System.out.println("You entered " + y);
System.out.println("Do you want to Divide(/) Mltiply(mult) add(add) modulus( or subtract(-)");
if (userInput.hasNext("/")){
z = x/y;
System.out.println("The Dividend is " + z);
}
if (userInput.hasNext("mult")){
z = x*y;
System.out.println("The product is " + z);
}
if (userInput.hasNext("add")){
z = x + y;
System.out.println("The sum is " +z);
}
if (userInput.hasNext("-")){
z = x-y;
System.out.println("The difference is " + z);
}
if (userInput.hasNext("%")){
z = x % y;
System.out.println("The remainder is " + z);
}
}
}
else{
System.out.println("error");
}
}
}
python (3.5) calculator:
n1 = int(input("what is your first number"))
op =input ("do you want to / * – + or **")
n2 = int(input ("what is your seccond number?"))
# these are what you want to ask the user
if op== "/":
awncer= n1 / n2
elif op== "*":
awncer = n1 * n2
elif op== "-":
awncer = n1 – n2
elif op== "+":
awncer= n1 + n2
elif op == "**":
awncer= n1 ** n2
#this is how the com. does the math
print(n1, op, n2)
print("this =")
print (awncer)
#this is how you print the awncer and how the com got
for strings, use the hasNext, not hasNextline if you want to chose each input, example:
if (userInput.hasNext("add")){
}
//calculator!!!!!!!
import java.util.Scanner;
public class calc{
static Scanner userInput = new Scanner(System.in);
public static void main (String args[]){
int z;
System.out.println("This is a basic calculator");
System.out.println("Enter Your First Number:");
if (userInput.hasNextInt()){
int x = userInput.nextInt();
System.out.println("yo entered " +x);
System.out.println("Enter your next number:");
if (userInput.hasNextInt()){
int y = userInput.nextInt();
System.out.println("You entered " + y);
System.out.println("Do you want to Divide(/) Mltiply(mult) add(add) modulus( or subtract(-)");
if (userInput.hasNext("/")){
z = x/y;
System.out.println("The Dividend is " + z);
}
if (userInput.hasNext("mult")){
z = x*y;
System.out.println("The product is " + z);
}
if (userInput.hasNext("add")){
z = x + y;
System.out.println("The sum is " +z);
}
if (userInput.hasNext("-")){
z = x-y;
System.out.println("The difference is " + z);
}
if (userInput.hasNext("%")){
z = x % y;
System.out.println("The remainder is " + z);
}
}
}
else{
System.out.println("error");
}
}
}
How did you get the console to only print your results and not the class path (or whatever it is?)
great explanation….i am finally able to code..thank you 🙂
Are these tutorials outdated?
Just a quick question, when u delete static from Scanner class, and just type Scanner userInput = new Scanner (System.in); it's throwing an error, why is it like that? Why do you have to put static for all methods and variables inside the class but not inside the main method? (when you just put scanner inside the main method, it works fine but when i just put scanner outside of that method it's giving me an error) great video, btw!
Er i return an error after using the else statement. Says "else without if". obviously there is no if but i can't compile it.
try {to not crash} catch(Exception ProllySomeNullPointer) {System.out.print("Hey, it happened again");}
Hi Derek, plz ignore. I figured it out after watching your tutorials a few more times.
Hi Derek, am writing code for password reset. Something is wrong. Need help. import java.util.Scanner;
public class LessonTwo
{
public static void main(String[] args)
{
Scanner input = new Scanner(System.in);
System.out.print("Do you wish to change your password?");
if(input.hasNextBoolean();
{
Boolean trueOrFalse = input.nextBoolean();
System.out.println(trueOrFalse);
}
}
}
System.out.println ("This brain has stopped working, can't reboot to stupid")
Hi Derek, your teaching method is really good. Am a newbie in Java and it helps in understanding.