Added: 2 years ago
From: thenewboston
Views: 125,977
Sort by time | Sort by thread (beta)

Link to this comment:

Share to:

All Comments (243)

Sign In or Sign Up now to post a comment!
  • Is it true that the ELSE IFs order matters????? The program would return the printout for the first TRUE condition???

  • @TheTingism but if its greater than or equal to it does matter, because if you had age>=40 first and then age>=60 and u had the age 65 inserted, it would say ur in ur 40s because 40 was first

  • lol so they get russian on a makeshift security guard lol

  • @dragonthewatcher so again thank you and ill see you next door (as he winks)

  • these are so helpful, thanks man, keep up the hard work

  • what now you do not need to have {}

  • @gustavboll1 because because it is a single line of code

  • @Metgeoz ok...

  • you really right-clicked and copy? You're a programmer dude!!

    You spelled Ctrl + C and Ctrl + V wrong

  • constructors were kinda more fun than if else statements

  • @slim2kev Yes, so as to me. :)

  • @slim2kev Nah, I think if else statements are more fun.

  • Why not use a Switch statement?

  • @6dark6alex6 In switch statement, you can only test the value of one variable, while there you can do else if (1 > 0), things like this.

  • @6dark6alex6 Switch can only be used with specific values like 1-100 and so on or A-Z/a-z

  • lol bucky knows almost every programming language you can imagine but he doesn´t know how to use Ctrl+C and Ctrl+V

  • @JakobRobert00 he knows c+... i know +C ^^

  • Comment removed

  • @JakobRobert00 Well, maybe does his keyboard not contain a ctrl key.

  • @JakobRobert00 I don't think he cares to even use it. He's just trying to show the basics from the basic forms without using those shortcuts.

  • its fun to watch how the view counter falls when we get more into the series xD

  • when do you learn how to make a game?

  • @MrSilentknight12

    depends on your work, mby less than half year

  • How The F Dislikes This????!!!!???

  • THIS IS NOT OUTPUTTING ANYTHING!

  • "so they get a russian on makeshift security men share of"

    Nice one google...

  • I just have one giant java project which asks you questions that make no sense, but I try and apply all the new things I learn from these tutorials into it. I would suggest anybody who's having trouble to do the same since it really gets you familiar with the language.

  • "In the middle of the if and else, you put something called an 'else if'" Very creative name.

  • double first; double second = 0; String plussminus; double sum = 0; Scanner input = new Scanner (System.in); System.out.print("First number: "); first = input.nextDouble(); System.out.print("Plus or minus?"); plussminus = input.nextLine(); if (plussminus == "Plus") { sum = first + second; } else if (plussminus == "-") { sum = first - second; } else { System.out.print("You did something wrong.");} System.out.print("Second number: "); second = input.nextDouble(); System.out.println(sum);
  • @SathApoc i know this looks really wierd, but i had to make it like that to have enough space. Can someone tell me why this dosnt work? First number worked fine, but after i typed a number, then enter, it just says "Plus or minus?You did something wrong.Second number: ", and if i write a number, i get 0.0. Any help? :)

  • @SathApoc Try using two different Scanners for double and string type

  • These are great man. Thanks!

  • Java is complicated, and you make it simple. Only 68 more to go. Thank you!

  • here if you put "if age >=40" higher than "if age >=50", then you are going to be in your 40s even if you are in your 80s ...=\

  • @Everlovingful thats what tutorial 11 goes over you can use for example "If age >=40 && age <=49" Pay attention! :P Good luck!

  • Comment removed

  • @Everlovingful Yeah sure if you do something wrong, the outcome is wrong.

  • Have a 7 1/2 hour trip to gmas for thanksgiving... what am i doing? watching bucky :)

  • Comment removed

  • 1. Turn on the subtitles

    2. Go to 4:00

    :D

  • @runika1000 masturbation store :)

  • @runika1000

    Good translation skill. (I mean google)

  • @runika1000 :)

    Wow! this is very philosophic quote "If you wanna be dumb but, in a masturbation store!"

  • @runika1000 4:25 is slightly funny too :P

  • I really like these tutorials, you're kinda funny and you do a good job, hopefully I'll be a Java programmer by New Year's Eve.

  • Comment removed

  • Comment removed

  • @TheDemonStr I have made a program that can calculate that.

  • I cant figure out what i should write if i want to be able to first type in the age, and then get the answer. Ive imported the scanner, i wrote: Scanner age = new Scanner(System.in); and after that: age.nextLine(); when i write the if statement, using the variable age, it doesn't work? :( What have i donw wrong? help please!

  • test other variables if you want to be dumbbb lol

  • I'm confused now.... why don't you need the curly braces anymore?

  • @SPlRO If the if statement is one line, you dont need a curly brace. The same applies to else statements. But, the only exception is in nested if statements. you can have

    if (x>6)

    if (x>7)

    print..dsdfghsflgjhdfgh

    else

    printaksdfhlks

    else

    print skgljhsaklgj

    without any curly braces needed

  • @SPlRO curly braces are for organizational purposes... Very good to get used to because when you get farther in its hard to keep track of what is inside of what.. As well as nesting statements..

  • lol 4:02 click transcribe audio :D

    on masturbation store on and elsif same and how to use in java programming

  • @N1gh7Sh4d3 LOL and at 4:24 :

    so they get a russion on makeshift security men share of

  • understood it finally thx

  • I like how the views slowly dimish the further along I get.

  • 0:27 I thought you needed curly brackets to make an if statement? :O

  • @afferik You do but i think his recording system is glitching

  • @PWNR1234

    You don't really need (at least not for these simple conditions). But once the conditions become many and comprehensive, it gets much more organized and structured with curly brackets, and I believe in some cases you'll actually get errors without them. not sure tho ;)

  • @7LFproductions

    Ok all three of you I'm going to clear up the misunderstanding. When you have 1 action inside the if statement, curly braces are NOT necessary. However, when you want multiple actions inside the if statement, you have to use curly braces. If you don't, the program probably will not get an error, but the 2nd, 3rd, 4th, etc. actions will perform even if the if condition is false, because they are not part of the whole if this then do that thing.

  • How does the else if statement vary from a switch statement?

  • @bluestreak711 with an else if statement you can make like this:

    int age = 55

    int boys = 23

    if (age <= 60)

    System.out.println("Too young!");

    elseif (boys == 23) then

    System.out.println("Too many boys!");

    with an switch statement you cant check if any other variable is something, switch statement has a certain variable

  • when i was taught programming in the beginning , else if statements we strongly discouraged and having only 2 conditions with nested if statements were widely used.. I still use this principle to this day! sometimes when im working on a larger project and feel lazy will i create more than 2 conditions using the else if statements :P oh how programming has evolved!

  • i dont really see the use of this one...you can simply type IF again instead of else if and you will get the same results =/

  • @ChrisTheBest1992 it is considered good syntax to use else if statements because on a larger scale a program will run more efficiently or quicker if you use if/else rather than seperate if statements.

  • i just saw there are 86 tutorials o.O SWEEEEET!

  • Awesome tutorial but wouldnt it make more sense if you could enter ur age and after that it told you "youre in your 40s" or whatever? (and i know, there is another tutorial on how to do that stuff)

  • Getting there...

  • why can't you put just a buch of if's?

  • @soldado1997 that why he's explaining this becus it saves you time doing this

    and its more efficient

  • @soldado1997 to make it less confusing

  • @soldado1997 Because if you just put a bunch of if's, it'll test each one and if you put one if and all the following ones as else if, once a test comes out positive, it doesn't go on to check the rest of the tests!

  • @thenewboston Thank you, You have made learning java allot easier! :)

  • Comment removed

  • Couldn't you just use a 'switch' statement for this?

  • @Jonyinc ya but he is teaching else if so thats why.

  • Ah, so else if is the same as writing an if statement inside another one?

  • @kmncztms Yup, just cleaner and easier

  • Im watching this, But I'm really only on episode 3, Waiting for eclipse to download XD

  • @Allenmarxchannel same here ^^

  • @Allenmarxchannel I think you won't learn anything about it! :D

  • wouldn't this work if you just used a switch statement with mutiple cases?

  • @doody884 yes. But he is teaching else if statements...

  • Ha! I made bmi calc when he teached math and if statements, this should be teached earlier 'cause this is important. Also remember to apply the contents of these tutorials and you'll discover more and most importantly learn.

  • is this same as VBS?

    i m learning vbs and i wanna know it?

    thank you

  • @the147break its not but its kind of similar

  • portal 2 "Testing for science!"

  • Oh god. Still 60 more to go! T.T

  • @PinkyTheTroll yah in 8 episodes, aye aye aye, 68 eoisides DX

  • Aren't "nested if statements" (the previous tutorial) and "else if statements" the same thing? The only difference I can see is that for "else if", you put "if" BESIDE "else" rather than on a new line.

  • @MisterM2402 the nested if statements will make it print two lines (the initial statement then the nested one) The else if only prints whatever line applys

  • the heck happened to the brackets in the if statements!!

  • whats the difference between the switch command?

  • he needs to learn the shortcuts for copy and paste

  • ok so i was going smoothly through all of his tutorials until his brackets started ending up farther to the right then mine...idk wth has happened but now my code gets all messed up :/ help plz...

  • @t89pepper What do you mean by his brackets started ending up farther to the right then yours? If you mean that some of his code seems to be more to the right than yours is, that doesn't really matter. What matters is that the syntax is correct. Make sure all of the curly braces are properly opened and closed, and that you have semi-colons where there should be, and it should work fine.

  • you know you can just ctrl+c to copy and ctrl+v to paste?

  • @hcbtGaming oh ya lol

  • 19 down... 68 more to go.. :) thanks Bucky.

  • Whats the difference here between switch and this?

  • @98Tul else if is more flexible and can be > < whatever rather then only ==

  • You make Java programming look so easy.

  • hahaha this is so easy :}

  • any reason why you'd choose to use massed else-if statements over a switch statement in an IRL case?

  • @LeftRight1511 Can you use Chars and Strings in switch statements?

  • @LyriiczBoii yup

  • keep the good work... love your tutorials.

  • Hey guys answer me please. How do I use "if" statement from user input. For example. System.out.println("Are you a MALE or a FEMALE, type f/m: "); , I want to use an IF statement that is going to react based on what I type to the program (f, or m) Please help thanks

  • @fearlessftw Make a variable(string or char it doesnt matter) to save the information you are going to scan. after that use of the if statement with the variable you just created... my suggestion use an elseif in case the person make a mistake and type something different from M or F

  • Comment removed

  • "if you wanna be dumb...but uhm" x)

  • its always funny how that in a series of tutorials the people viewing get less and less as the lessons go on

  • @JamesCalex

    The last java video has only 300+ views, and its been up since last year.

  • @JamesCalex true programmer get reviled. And idiots who were just along on the ride to "prove to them selves" that they can learn java quit. caz they can't processes the awsomeness of java :D

  • @JamesCalex Exactly. That's what I am noticing..Viewers go down when tutorial goes up. All losers.

  • hi is that must u have to end with single Else what happen if we put elseif in our last else

  • this is the same as a switch statement

  • @TheWondererMan no no no no this is completly different thing. Switch statement is for exact numbers (if im not frong) and if is more for not so exact numbers. Switch for 1,2,3,4,5,6... and if for numbers between 2 numbers. And that should have made sense..

  • @zedo28 Can't If statments be also used for text input?

  • @ProverHeartAnnalia Yeah.. I personally use if even if switch can be placed

  • Bucky, you are so great, i've looked for so many tutorials but every tutorial sucks, but if i look at your, it looks so simple!

    thanks alot man, much appreciated!!!!!!!!!!!!!!!!!!!­!

  • why dont you need {}'s for this one as opposed to single if statements?

  • goooooooooooood

  • do you have tutorial for JOptionPane?

  • coming from python we use elif for else if. for java does else if have to be between if and else? or can it be used like python one if and the rest elif?

  • @Dusty2084 You don't need to have the last "else" in it but you need the first "if"

  • It's funny how after each video, the number of views decrease...shows how much dedication and determination people have for the language...quitters! =P

  • thanks for these vids

  • 3:57 lol " If you wanna be dumb but..."

  • You sir, should sell this stuff on DVDs!

  • There are a ton of these things: If statements, switch statements, nested if statements, else if statements...

    I think you can make the same program with any of them, but some are faster. So far I feel nested ifs are a little too confusing for my taste, and switch statements seem to work perfectly fine for most things.

  • Comment removed

  • Does anyone know how to use a string imported from the scanner in a switch/if/else if statement. I really need to be able to do that for a program im working on.

  • @NEDinACTION import the scanner (import java.util.Scanner;) create the class System.out.println("Enter your string"); Scanner yourScanString = new Scanner (System.in); String yourTestString = scan.nextLine(); if (yourTestString == whatever){ enter code if result is true. else{ enter code if result is false } } If you want if else, switch, case etc. It is EXACTLY as he has shown in videos, just save the input to a string, and use the string as the test variable.
  • Thanks for making these videos, man.

  • so, else if statment are kinda like switch statement?

  • Cool. I am a young buck!

  • bucky the java slayer

  • else if statements > if else statments .... else if statements are so much easier to do.

  • can u help me cuz i want age = user input how do i do that?

  • 6 people missed the Like button :P

  • If I recall it correctly, didn't the past videos use: main(String args[]) while this one uses main(String[] args) lol... what's the diff?

  • If I recall it correctly, didn't the pass videos use: main(String args[]) while this one uses main(String[] args) lol... what's the diff?

  • Guys, just so you know what you learned today here's a quick sumaray. Else if statements are convieneint because it saves you the trouble of making multiple if statements which reuire a new set of braces each time you type them. Else if statements are more like switch statements-easy to type, simple, and neat-, but they are not nearly as specific as switch statements because you can choose from a wide range of numbers. Switch statements can only select one number at a time.

  • older people must hate you xD

  • @TheGreekSkater The else if-statement is like the else-statement but with a condition. So if the if-statement before an else if-statement is false but else if is true the code in else if will be executed. If they're both true only the if-statement will be executed.

    If you use two if-statements instead both will be executed if they're both true.

  • Isn't this just an easier, tidier way to do the Nested If's? As I wrote up something from ages <=5 to over 120. With different replies, using the nested ifs like If THIS! do that }else{ If THIS! do that }ELSE{ then i had lots of }}}}}}} at the end of the script. Then I've just shortened that script I wrote by using:- If THIS do that ELSE IF THIS do that ELSE IF THIS do that ELSE do this. Or is there another use for Nested If's? did i miss something? :S pls help someone, Tnx!
  • "Syntax error on token "else", delete this token" this is what i get when i put the else statement under the else if.

  • whats the difference between writing "if" or "else if"

    you can just write another "if"

  • Quick question, using a switch statement would do the same, correct?

  • @indieology I dont think you can test if a number is between a certain range with a switch, e.g (age >=50 && <60)

    I might be wrong, Just tried it and it didnt work, someone can correct me if Im wrong

  • @ST34LTH1 You just have to add age before <60, so you always have to say what you want to compare with what.

  • the braces can be omitted if no multiple actions will be executed if you will only print a string, you may not include a brace as long it is included in the if or else statement :)

  • Thank you so much : ) I have a Computer Programing Final Exam tomorrow and I never really understood if/else statements. Great for review :D

  • so you dont really need curly brakets or what ever for your code?

    example:

    if(whatever) { System.out.

    }else{ System.out.

    you can do that with out the brakets?

    so whats the point of sometimes putting them and sometimes not???

  • @AliahBishr if You dont put brackets You can only add one next line, if you put two or more it will prompt an error, so it safer and cleaner to put those bracketes every time imo, e.g. when you want to put another line of code later on

  • @mufaPufaDha Oh ok lol thanks 

  • @AliahBishr the only two solution i came up with is that braces consume time when computer is reading them so first programmers decided to gain some time and exclude braces from one line statements when it was possible, but thats pretty stupid imho... OR, they have small terminals that displayed only like 24 lines of code which is more possible i think. "(...)By bracing every if, else, while, etc.—even single-line conditionals— insertion of a new line of code anywhere is always "safe"."

  • @mufaPufaDha Ok :) thanks

    So its better that I use the braces always instead of leaving them out sometimes right?

    thanks for the tip..highly appreciated

  • Bucky, you rock! Just one comment, your previous 'IF' tut used curly braces around the 'IF' and corresponding 'ELSE' statements, in this tutorial you omit them; is it better to do it with or without curly braces?

  • @vinchisel If you need more than 1 line of code in your if/else/else if statements, use curly braces. If you only need 1 line, it doesn't really matter.

  • instead of

    int age=60

    type this .

    Scanner reed=new Scanner(System.in);

    int age;

    System.out.println("enter your age");

    age=reed.nextInt();

    now you are able to type your age and run your programme perfectly

  • wait what?? you didnt even put brackets on those and they worked

  • Eclipse is telling me "Syntax error on token "else" delete this token."

    I'm confused. :/

    class cake { public static void main(String[] args) { int age = 55; if(age > 60); System.out.println("You're a senior citizen."); else System.out.println("You're a young buck."); }

    }

  • @datshortkid1

    Never mind. I had to remove a ; lol