Learn Java Tutorial for Beginners, Part 6: If

Java

Video is ready, Click Here to View ×


Get complete courses at http://courses.caveofprogramming.com
The if() statement in Java, plus “break” for breaking out of loops.

21 thoughts on “Learn Java Tutorial for Beginners, Part 6: If

  1. Quick question if I may – I am using Eclipse 4.9.0

    if(cond = true)
    System.out.println("Yes it's true");
    else if(cond = false)
    System.out.println("That isn't true");

    I set a statement that cond is false however my if else always prints the first line. Also have the curly brackets been depreciated, Eclipse referred to them as dead code.

  2. I've been programming in app inventor for 2 years and it took me a long time to figure out how to use the "else if". The whole purpose of it is so powerful, it could be used to make a computer appear as though it was intelligent and have a conversation with people to pass the Turing test.

  3. how come it says "syntax error" when i try to do the last "else" string ("None of the above"). I have Eclipse Luna but no JRE cause that's included in JDK right? Idk what difference that makes. How come mine doesn't execute? Help! LOL 🙂

  4. Is it okay if I just make The Code Like This?
    while(true) {
    System.out.println("Looping: " + loop);

    if(loop == 5) {
    break;
    }
    else {
    loop++;
    }

    System.out.println("Running…");

  5. This is my little code I came up with with your tutorials. 

    public class trying {

    public static void main(String[] args) {

    int lol = 0;
       while(true){
        if (lol< 4){
        System.out.println("nope, lol =" + lol);
        lol++;
       
        }
       }

    }

    }

    When I take this class in college I'm going to kick butt lol

  6. Just want to say thank you for your tutorial! I decided to learn Java a little (i had no dev practice before at all and no knowledges about it) and your tutorial helps me a lot! Really cool, thanks for it!

Leave a Reply

Your email address will not be published. Required fields are marked *