Java Video Tutorial 2

Java Video Tutorial 2

FavoriteLoadingAdd to favorites

CODE IS HERE:

Java468x60

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

By |2020-01-04T00:59:26+00:00January 4th, 2020|Java Video Tutorials|29 Comments

29 Comments

  1. Jawad Elmokhliss January 4, 2020 at 12:59 am - Reply

    Up

  2. Maxim Chowdhury January 4, 2020 at 12:59 am - Reply

    Are there any Anki decks made for this series?

  3. Gregory R.H. January 4, 2020 at 12:59 am - Reply

    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.

  4. argonaut11 January 4, 2020 at 12:59 am - Reply

    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!

  5. Matt Graves January 4, 2020 at 12:59 am - Reply

    🙂
    '…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…

  6. Dishon Fano January 4, 2020 at 12:59 am - Reply

    Great tutor here…Kudos Derek

  7. Mark Aitcheson January 4, 2020 at 12:59 am - Reply

    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!

  8. philborg January 4, 2020 at 12:59 am - Reply

    awesome but you sound like brian regan, which makes it better

  9. Brijesh Goyal January 4, 2020 at 12:59 am - Reply

    '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?)

  10. Emese Barok January 4, 2020 at 12:59 am - Reply

    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!

  11. Tifrea Vlad January 4, 2020 at 12:59 am - Reply

    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

  12. Bleard Osmanoviq January 4, 2020 at 12:59 am - Reply

    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

  13. ronjeremy123 January 4, 2020 at 12:59 am - Reply

    can you help me use a text file to get arguments for a method

  14. Curiosity 47 January 4, 2020 at 12:59 am - Reply

    You are just a boss.Keep going

  15. Kyle Guerrero January 4, 2020 at 12:59 am - Reply

    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?

  16. Harish Thevakumaran January 4, 2020 at 12:59 am - Reply

    could u have that scanner object inside the main method or is it supposed to be outside the main method?

  17. nicholas begg January 4, 2020 at 12:59 am - Reply

    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

  18. nicholas begg January 4, 2020 at 12:59 am - Reply

    for strings, use the hasNext, not hasNextline if you want to chose each input, example:

    if (userInput.hasNext("add")){
    }

  19. nicholas begg January 4, 2020 at 12:59 am - Reply

    //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");
    }

    }

    }

  20. iwannaapple January 4, 2020 at 12:59 am - Reply

    How did you get the console to only print your results and not the class path (or whatever it is?)

  21. Pulkit Agrawal January 4, 2020 at 12:59 am - Reply

    great explanation….i am finally able to code..thank you 🙂

  22. Khaled Ban January 4, 2020 at 12:59 am - Reply

    Are these tutorials outdated?

  23. Alice Kim January 4, 2020 at 12:59 am - Reply

    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!

  24. Bjorn Livingston January 4, 2020 at 12:59 am - Reply

    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.

  25. Jacob Gasser January 4, 2020 at 12:59 am - Reply

    try {to not crash} catch(Exception ProllySomeNullPointer) {System.out.print("Hey, it happened again");}

  26. Sushma Narayan January 4, 2020 at 12:59 am - Reply

    Hi Derek, plz ignore. I figured it out after watching your tutorials a few more times.

  27. Sushma Narayan January 4, 2020 at 12:59 am - Reply

    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);

    }

    }

    }

  28. Klab January 4, 2020 at 12:59 am - Reply

    System.out.println ("This brain has stopped working, can't reboot to stupid")

  29. Sushma Narayan January 4, 2020 at 12:59 am - Reply

    Hi Derek, your teaching method is really good. Am a newbie in Java and it helps in understanding.

Leave A Comment

*