Java Programming Tutorial 21 - Switch Statement

Поділитися
Вставка
  • Опубліковано 12 гру 2024

КОМЕНТАРІ • 118

  • @codebreakthrough
    @codebreakthrough  5 років тому +7

    Learn Javascript - bit.ly/JavaScriptPlaylist
    Learn Java - bit.ly/JavaPlaylist
    Learn C# - bit.ly/CSharpTutorialsPlaylist
    Learn C++ - bit.ly/CPlusPlusPlaylist
    Learn C - bit.ly/CTutorialsPlaylist

    • @DrWho2008t101
      @DrWho2008t101 4 роки тому

      thanks for the video.

    • @marco7838
      @marco7838 3 роки тому

      I got this as the "if" statement version. I have changed a few things but please let me know if the concept is correct!
      public static void main(String[] args) {
      System.out.println("What is your name?");
      String name1 = "Caleb";
      String name2 = "Monica";
      Scanner scanner = new Scanner (System.in);
      String name = scanner.nextLine();
      if(name.equals(name1)) {
      System.out.println("You are male");
      }
      else if(name.equals(name2)) {
      System.out.println("You are female ");
      }
      }
      }

  • @Martin-wz5rm
    @Martin-wz5rm 5 років тому +70

    if (name.equals("caleb") || name.equals("clare")){
    System.out.println("Go away');
    }
    else{
    System.out.println("Try again later");
    }
    That's my solution, i hope it has no errors!

    • @bozhidarchavdarov94
      @bozhidarchavdarov94 5 років тому +28

      On the "Go away" there is an error because of the single quote at the end ;) You should close it with double quotes.

  • @biggbrotther5052
    @biggbrotther5052 5 років тому +19

    You are THE BEST JAVA TEACHER I ever had !!! Thank you for all tutorials !!!

    • @rittenbrake1613
      @rittenbrake1613 4 роки тому +2

      absolutely

    • @CrazyChaosClara
      @CrazyChaosClara 4 роки тому

      definitely if it wasn't for Caleb id fail my exam. Couldn't understand anything until I researched on UA-cam!

  • @matthewhenington8139
    @matthewhenington8139 5 років тому +27

    Clare is like a recurring theme throughout these videos and I've never wanted to know more about someone's life until I watched these videos. Who tf is Clare?? We need to know!

  • @allenzhou5881
    @allenzhou5881 5 років тому +25

    Wow! Pramp?!?? I've never been able to do well in an interview... But with Pramp, I'll get off the streets for sure!

  • @matttantony4077
    @matttantony4077 5 років тому +3

    Props to you Caleb. Before I watched this video I had never even heard of the switch statement, let alone used it in coding. Thanks to you I now feel like I know exactly how to use it with confidence. You explained it brilliantly in 8 minutes. Thank you! :)

  • @leviconnelly8553
    @leviconnelly8553 6 років тому +8

    I love your videos, Caleb! I'm taking Java Programming this semester in college, so this is extremely helpful!

  • @crookedlobster1905
    @crookedlobster1905 5 років тому

    if (name.equals("Caleb")) {
    System.out.println("Welcome my man");
    } else if (name.equals("Clare")) {
    System.out.println("Go away");
    } else {
    System.out.println("Try again later");
    }
    Thank you so much for these tutorials!

  • @ortaseleaisuan6770
    @ortaseleaisuan6770 3 роки тому

    Woowww, I'm glad that I'm finally learning something. I also made a switch statement for fun. Here y'all go:
    System.out.println("Who are you?");
    Scanner scnr = new Scanner(System.in);
    String student = scnr.nextLine();
    switch(student){
    case "Melissa":
    System.out.println("Welcome" + '\t' + student + "!");
    break;
    case "Sammie":
    System.out.println("What's up " + student + "?");
    break;
    default:
    System.out.println("I dont even know you dog :/");
    break;
    }

  • @joshuamorris144
    @joshuamorris144 4 роки тому +2

    i am finding this series incredibly useful. im doing engineering in university and im required to learn java. they really skipped over most of the important basics. im at the start of semester 2 and they only just wrote out a list of all primitive types where they expected us to use them like pros throughout semester 1 lol

  • @cameraday9196
    @cameraday9196 3 роки тому

    if (name == "caleb") {
    System.out.println("Weclome my man!");
    String Access = "yes";
    }
    if (name == "clare") {
    System.out.println("Go away");
    String Access = "no";
    }
    else {
    System.out.println("Try again later");
    String Access = "no";
    // I added the variable Access to simulate what it would probably be in real life to show the rest of your code that // the user does or does not have Access to your program.
    // He was right about it having more Syntax. Although from my knowledge of python this code makes more sense // to me than the one he described in the video.

  • @Martin-wz5rm
    @Martin-wz5rm 5 років тому +16

    just like c++, i think knowing c++ made all these series easier.

    • @tomcat9761
      @tomcat9761 4 роки тому

      does it apply also in learning java first and c++? vice versa? i'm learning java first and maybe after this i'm going with c++ lol

    • @rupertacuesta
      @rupertacuesta 4 роки тому

      @@tomcat9761 I think because c++ is a harder language to learn where there are a lot of complex concepts.

    • @Andrew-xs4qy
      @Andrew-xs4qy 4 роки тому +1

      once you learn a lanuage you can apply it to the others,

    • @PROMAN8625
      @PROMAN8625 3 роки тому

      me knowing a bit of every coding language and doing this type of code from 2 years in java script
      lol

  • @JODECIFEENIN
    @JODECIFEENIN 5 років тому

    you made me under stand this on a another level not boring

  • @michaelaalquino7878
    @michaelaalquino7878 4 роки тому +2

    The way you introduce pramp in different ways every episode makes me laugh so hard and make me guess how will you do it on the next ep lol

    • @tomcat9761
      @tomcat9761 4 роки тому +1

      tama..haha tsaka chill lang siya magturo lol

  • @akashshah3356
    @akashshah3356 5 років тому +5

    I Like your approach of teaching Java Programming. I appreciate you for investing your time to educate people like us. Thanks, Keep 'em coming! :)

  • @trumbaron
    @trumbaron 2 роки тому

    How to make use of switch without the break statement. You can ask the user how many things should be excecuted (cases). If you put the cases in reversed order: case 3: do this (no break), case 2: do that (no break), case 1: do some other stuff (no break). If the user enters 1, only thing one is done. If the user enters 2, then thing number 2 and then 1 is done. If the user enter 3, all three things are done.

  • @ortaseleaisuan6770
    @ortaseleaisuan6770 3 роки тому

    Omgoodness After all this time of struggling, I finally understand. Thank you Caleb
    System.out.println(happy face emoji with one tear); Lmaoo. Here is my if statement of my own tho ;P.
    System.out.println("What is your name?");
    Scanner scnr = new Scanner(System.in);
    String name = scnr.nextLine();

    if(name.equals("Johnny")){
    System.out.println("What's Poppin :P");
    }
    else if(name.equals("Tommy")){
    System.out.println("Heyyyy"+ '\t' + name);
    }
    else{
    System.out.println("Nah fam, you gotta go, GoodBye.");
    }

  • @rittenbrake1613
    @rittenbrake1613 4 роки тому +2

    I think u can go to dub for Disney's movies with that voice of promoting Pramp

  • @christianmetaldreamur3491
    @christianmetaldreamur3491 5 місяців тому

    It seems to me like break is just serving a simular function to a closing curly brace. It is different in certain ways of course, but both of them seem to be some kind of closing syntax.

  • @PROMAN8625
    @PROMAN8625 3 роки тому

    07:33 the code ( i didn't tried this in an ide )
    if (name == "caleb"){System.out.println("Go Awaw!!");
    else if (name == "clare"){System.out.println("Go Awaw!!");}
    else {try again later}

  • @hihellookay123
    @hihellookay123 11 місяців тому

    Day 2 🙌 Done 21 out of 100, 79 more to go let's go! 🔥

  • @zaglulhaider758
    @zaglulhaider758 5 років тому +1

    Scanner scanner = new Scanner(System.in);
    System.out.println("What is your name?");
    String name = scanner.nextLine();
    String Rubel = new String("Zaglul");
    if(name.equals(Rubel)) {
    System.out.println("Welcome " + Rubel + " we are waiting for you");
    }else {
    System.out.println("Please try agai later");
    }

  • @28MannyR28
    @28MannyR28 5 років тому

    import java.util.Scanner;
    public class MySweetProgram {
    public static void main(String[] args) { // method
    System.out.println("What's ya name?");
    Scanner scanner = new Scanner(System.in);
    String guess = scanner.nextLine();
    String name = "Manuel";
    if(guess.equals(name))
    {
    System.out.println("Welcome my man!");
    } else if(guess.equals("Jane"))
    {
    System.out.println("You ain't no girl!");
    } else
    {
    System.out.println("Try again.");
    }
    }
    }
    (Thanks for these vids Caleb, you're awesome!)

  • @silvgn7877
    @silvgn7877 2 роки тому

    Is it a good idea to combine Caleb and Clare though 7:19

  • @PROMAN8625
    @PROMAN8625 3 роки тому

    basically
    if are actual conditions where as switch needs "'EXACT'" statement

  • @spencernold8899
    @spencernold8899 5 років тому +6

    if (name.equals("Caleb")) {
    // Code
    } else if (name.equals("Clare")) {
    // Code
    } else {
    // Code
    }

  • @kayheart4402
    @kayheart4402 5 років тому +1

    hahaha for once i actually enjoy learning how to program you make it fun...and you nailed the Ad

  • @okmaydog3945
    @okmaydog3945 3 роки тому

    I'm not sure if this will work on other programs but IntelliJ fixed my switch state with multiple cases to this: switch (name) {
    case "johnny", "appleseed" -> System.out.println("big apple");
    default -> System.out.println("go smoke some appleseeds");
    }
    looks like you can use -> as a substitute for :.

    • @PROMAN8625
      @PROMAN8625 3 роки тому

      thanks for the knowladge
      this code works in vs code

  • @spartanspeedruns8386
    @spartanspeedruns8386 4 роки тому

    Scanner scanner = new Scanner(System.in);
    String Caleb = "Caleb", Clare = "Clare";
    String input = scanner.nextLine();
    String name = input.toLowerCase();
    if (name.equals(Caleb.toLowerCase()) || name.equals(Clare.toLowerCase()) {
    System.out.println("Go away");
    } else {
    System.out.println("Try again later");
    }
    I wonder if I messed anything up. Half of this I learned today, and half I learned like 8 years ago lol.

  • @yes1543
    @yes1543 4 роки тому

    Thank u so much Caleb! Lots of love😚

  • @christianmetaldreamur3491
    @christianmetaldreamur3491 5 місяців тому

    Here is my full code for this episode, including for the switch statement and an if statement version. I will be using characters from a story of mine for names in this. :)
    package ep018to0XX;
    import java.util.Scanner;
    public class Ep021SwitchStatement {
    public static void main(String[] args) {

    Scanner scanner = new Scanner(System.in);

    System.out.println("What's your name?");
    String name = scanner.nextLine();

    switch (name)
    {
    default:
    System.out.println("Hmm, your not on the list, so I can't let you in. Have a nice day though!");
    break;
    case "Sam":
    case "Nealy":
    System.out.println("Welcome in my dude!");
    break;
    case "Rjinder":
    System.out.println("GO AWAY YOU MONSTER!!!");
    break;
    }

    if (name.equals("Sam") || name.equals("Nealy"))
    {
    System.out.println("Welcome in my dude!");
    } else if(name.equals("Rjinder") )
    {
    System.out.println("GO AWAY YOU MOSTER!!!");
    } else
    {
    System.out.println("Hmm, your not on the list, so I can't let you in. Have a nice day though!");
    }

    }

    }

  • @syandiswambatha1117
    @syandiswambatha1117 2 роки тому +2

    import java.util.Scanner;
    //Prompts the user to input their name, if it is 'Syandiswa', the app opens
    public class TaskOnIfStatements {

    public static void main(String[] args) {
    System.out.println("What is your name?");

    Scanner scanner=new Scanner(System.in);
    String name= scanner.nextLine();

    if(name.equals("Syandiswa"))
    {
    System.out.println("Hi, Welcome");
    }
    else if(name.equals("Mandisa"))
    {
    System.out.println("Hi, Welcome.");
    }
    else
    {
    System.out.println("Go away");
    }

    }
    }

    • @syandiswambatha1117
      @syandiswambatha1117 2 роки тому

      import java.util.Scanner;
      //Prompts the user to input their name, if it is 'Syandiswa' or Mandisa, the app opens
      public class TaskOnIfStatements {

      public static void main(String[] args) {
      System.out.println("What is your name?");

      Scanner scanner=new Scanner(System.in);
      String name= scanner.nextLine();

      if(name.equals("Syandiswa")|| name.equals("Mandisa"))
      {
      System.out.println("Hi, Welcome");
      }
      else
      {
      System.out.println("Go away");
      }
      }
      }

  • @HyperActive94
    @HyperActive94 5 років тому

    excellent teaching Caleb

  • @nutanpanta9238
    @nutanpanta9238 4 роки тому

    System.out.println("What is your name?");
    Scanner scanner=new Scanner(System.in);
    String name=scanner.nextLine();
    if(name.equals("caleb")||name.equals("clare")){
    System.out.println("Go Away");
    }
    else{
    System.out.println("Try Again Later");
    }

  • @iqmal3910
    @iqmal3910 2 роки тому

    This is the best intro ever💀😂

  • @zacharybarrett7827
    @zacharybarrett7827 4 роки тому

    "MySweetProgram" got me deadd

  • @gusfalk
    @gusfalk 4 роки тому

    How would you make it possible to also add the integer "1" as a command for System.out.println("Loads file"); in this switch case below?
    System.out.print("Name the command: ");
    String command = input.nextLine();

    switch (command) {
    case "load file":
    System.out.println("Loads file");
    break;

  • @degrees7117
    @degrees7117 4 роки тому

    Scanner scanner = new Scanner(System.in);
    System.out.println("Enter name: ");
    String name = scanner.nextLine();
    if(name.equals("Caleb")) {
    System.out.println("Welcome my man");
    } else if(name.equals("Clare")) {
    System.out.println("Go away");
    } else {
    System.out.println("Try again later");
    }

  • @dopeydoggo775
    @dopeydoggo775 5 років тому

    import java.util.Scanner;
    public class MySweetProgram {
    public static void main(String[] args) { //method
    System.out.println("What's your name?");
    Scanner scanner = new Scanner(System.in);
    String name = scanner.nextLine();
    if(name.contentEquals("Caleb"))
    {
    System.out.println("Welcome my man");
    } else if (name.contentEquals("Clare"))
    {
    System.out.println("Go away");
    } else
    {
    System.out.println("Try again later");
    }
    }
    }
    Was so proud of this lmao

  • @xgamer553
    @xgamer553 3 роки тому +1

    if (name.equals("Caleb"))
    {
    System.out.println("Welcome Caleb ");
    return;
    }
    else if (name.equals("Clare"))
    {
    System.out.println("Welcome Clare");
    return;
    }
    else
    {
    System.out.println("Go Away");
    return;

  • @ya-...
    @ya-... 5 років тому

    //Here is the code I made during this video:
    import java.util.Scanner;
    class Hello {
    public static void main (String[] args) {
    Scanner scanner = new Scanner(System.in);
    String statement = "Write your name!";
    System.out.println(statement.toUpperCase());
    String name = scanner.nextLine();
    if ((name.toLowerCase().equals("caleb")) || (name.toLowerCase().equals("clare"))) {
    System.out.println("
    MAKE A CLARE FACE REVEAL!");

    }else {
    System.out.println("
    comment #WhoIsClare");
    }

    }
    }

  • @mukoyatimothy1737
    @mukoyatimothy1737 2 роки тому

    Is it possible to use "and" or 'or' in the case statement

  • @miguelandrepaja7932
    @miguelandrepaja7932 4 роки тому

    package hello;
    import java.util.Scanner;
    public class MySweetProgram {
    public static void main(String[] args) { //method
    System.out.println("What is your name?");

    Scanner scanner = new Scanner(System.in);
    String name = scanner.nextLine();

    if(name.equals("Caleb")) {
    System.out.println("Welcome my man");
    }
    else if(name.equals("Clare")) {
    System.out.println("go away");
    }
    else {
    System.out.println("Try Again Later");
    }
    }
    }
    I think there is a better way to do this but this works

  • @mr.meeseeks6549
    @mr.meeseeks6549 4 роки тому +1

    if (dogYears == 0) { // Like case 0
    // Print 0..14 years
    }
    else if (dogYears == 1) { // Like case 1
    // Print 15 years
    }
    ...
    else if (dogYears == 5) { // Like case 5
    // Print 37 years
    }
    else { // Like default case
    // Print unknown
    }

  • @ChrisLuigiTails
    @ChrisLuigiTails 5 років тому +8

    What's the deal with Clare?

  • @tontuwala3176
    @tontuwala3176 4 роки тому

    if ( name.equals(username) )
    {
    System.out.println("welcome");
    }
    else if ( name.equals(username) )
    {
    System.out.prinln("go away");
    }
    else
    {
    System.out.println("try again");
    }

  • @ahmedalferjani3514
    @ahmedalferjani3514 4 роки тому

    Lots of thanks

  • @carlpartridge2950
    @carlpartridge2950 5 років тому

    what do you use as an editor

  • @yohanniverse3552
    @yohanniverse3552 3 роки тому

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

    System.out.println("Enter Name");
    Scanner scanner = new Scanner(System.in);
    String x = scanner.nextLine();

    if(x.equals("Caleb")|| x.equals("Clare")) {
    System.out.println("Go Away");
    }
    else{
    System.out.println("Try Again Later");
    }
    }

    }

  • @Player_X_YT2
    @Player_X_YT2 4 роки тому

    Everyone: Karren
    Caleb: Clare

  • @zaraelalaoui8739
    @zaraelalaoui8739 4 роки тому

    if(name.contentEquals("Clare"))
    {
    System.out.println("go away");
    return;
    }
    else if(name.contentEquals("Caleb"))
    {
    System.out.println("go away");
    } else
    {
    System.out.println("try again later");
    }

  • @alfa8587
    @alfa8587 5 років тому

    When I get interviewed on pramp what I should choose out of the list there if I've done java only based on your channel, such as a data science, front end, back end, system design or something else?

    • @codebreakthrough
      @codebreakthrough  5 років тому +1

      Algorithms and data structures!

    • @alfa8587
      @alfa8587 5 років тому

      Thank you, Appreciate it! You are the best!

  • @TheHandOfFear
    @TheHandOfFear 5 років тому +1

    You literally said there was no good use for fall-through, then proceeded to immediately use fall-through.

  • @AllmightC94
    @AllmightC94 5 років тому

    Hi i have a question can we use the “toLowerCase” method with the switch statements, i try but couldn’t figure it out, i know we can do it with the “if else” but im not sure about this one??

    • @codebreakthrough
      @codebreakthrough  5 років тому +1

      I don’t think you can. I think 😏

    • @johnathonthomas9446
      @johnathonthomas9446 5 років тому

      You might be able to set Caleb and Claire as variable and then do Caleb.toLowerCase and vice versa

  • @lakhmeetsingh5580
    @lakhmeetsingh5580 4 роки тому

    if name = caleb
    system.out.println("Welcome my man")
    else if name = clare
    system.out.println("go away")
    else
    sysem.out.println(""Try again later")

  • @TheHandOfFear
    @TheHandOfFear 5 років тому

    Fall-through has lots of use cases. It shows up a lot in code. That's why it exists.

    • @codebreakthrough
      @codebreakthrough  5 років тому

      It should not be used.

    • @codebreakthrough
      @codebreakthrough  5 років тому

      I don’t really consider having two case labels together fall through.

    • @TheHandOfFear
      @TheHandOfFear 5 років тому

      @@codebreakthrough Except that's exactly what it is.

    • @codebreakthrough
      @codebreakthrough  5 років тому +1

      Hmm I guess it depends on how you look at it. to me, it does not *really* count as fall through!
      If we take a look at functionality over syntax, fall through is equivalent in nature to having an if statement with an else-if and an else, where the the if block is executed followed by the else-if block and else block (logically impossible).
      Having two case labels is the equivalent of having an || in an if condition. The condition can be met in more than one circumstance yet only one block is executed.
      Even languages such as C# will not allow fall through and will give a compiling error yet having two case labels is completely fine.
      Either way, fall through (executing code in a switch block without it being followed by a break) rarely is recommended. It’s the cause of too many errors and should be avoided when possible.
      Regardless, I think we are splitting hairs.
      Let’s move on to something more important, like pretty much anything 🙂

  • @eyueltafesse4816
    @eyueltafesse4816 4 роки тому

    with this entrance i am going to sign up for Pramp

  • @emilioalvarado7720
    @emilioalvarado7720 5 років тому

    good video men

  • @Fyrir.
    @Fyrir. 2 роки тому

    I was looking for @Clare in comments, did not find anyone.
    Good video though.

  • @jilliansechrest5906
    @jilliansechrest5906 3 роки тому

    public static void main(String[] args) {
    System.out.println("What's Your Name?: ");

    Scanner scanner = new Scanner(System.in);
    String name = scanner.nextLine();

    if (name.equals("Jilly")) {
    System.out.println("Welcome!");
    }
    else if (name.equals("Mia")) {
    System.out.println("HELL NO!");
    }
    else {
    System.out.println("Really?");
    }

  • @Archeryring
    @Archeryring 5 років тому

    import java.util.Scanner;
    public class MySweetProgram {
    public static void main(String[] args) {
    System.out.println("HWat's your name?
    ");
    Scanner scanner = new Scanner(System.in);
    String name = scanner.nextLine();
    if (name.equals("John Amend-all") || name.equals("Robin")) {
    System.out.println("Welcome to the Forest!");
    } else if (name.equals("Gisborne")) {
    System.out.println("Gow away a sort of evil!");
    } else {
    System.out.println("Go away!");
    }
    }
    }

  • @kj_32
    @kj_32 5 років тому

    Maybe leave the break out if you want to fall through with a generic message for all and a personal message for certain users.

  • @pcutter1
    @pcutter1 4 роки тому

    The reason I'm here is so I can finally stop slopping around.

  • @zebuluncovert
    @zebuluncovert 5 років тому

    If(name.equals(“Caleb”) || name.equals(“Clare”){
    System.out.println(“go away”);
    }

  • @tonylane1308
    @tonylane1308 5 років тому

    import java.util.Scanner;
    public class main {
    public static void main(String[] args) {
    Scanner input = new Scanner(System.in);
    do {
    System.out.println("What is your name? ");
    String hard_copy = input.nextLine();
    String name = hard_copy.toLowerCase();
    if (name.equals("caleb") || name.equals("claire"))
    {
    System.out.println("Go away!");
    }else {

    System.out.println("Try again later");
    }
    } while (true);
    }
    }

  • @bigollie006
    @bigollie006 6 років тому

    My Masterpiece:
    package hello;
    import java.util.Scanner;
    public class MyFirstJavaProgram {
    public static void main(String[] args) {

    System.out.println("What is your name boy?");
    Scanner scanner = new Scanner(System.in);
    String name = scanner.nextLine();



    if(name.equals("Edward") || name.equals("Mufasa")) {
    System.out.println("Thats a baller ass name bro! Can we be friends?");
    } else {
    System.out.println("IT DOESNT MATTER WHAT YOUR NAME IS!!");
    }

    } // end of main method

    } // end of program

  • @manuelvillagomez6970
    @manuelvillagomez6970 4 роки тому

    if(name.equals("Caleb")|| name.equals("Clare")
    System.out.println("Go away");
    else
    System.out.println("Try again later");

  • @ara_walkman861
    @ara_walkman861 5 років тому

    if (name.equals("Calob")) {
    System.out.println("Wellcome cool!");
    }
    else if(name.equals("Clare")) {
    System.out.println("You have no access");
    }
    else {
    System.out.println("Try later again!");
    }

  • @hristochipev
    @hristochipev 5 років тому

    if (name.equals("Caleb") || name.equals("Clare")){
    System.out.println("Go away");
    }else {
    System.out.println("Try again later");
    }

  • @zhrhmzhx
    @zhrhmzhx 3 роки тому

    if (name.equals("Caleb") || name.equals("Clare")) { //I tried using (name == "Caleb" || name == "Clare") but doesnt work //cause it's object types and compare the memory location
    System.out.println("Stash Away hehe");
    }
    else {
    System.out.println("Try again some other time dont forget to wear mask tho bye");
    }

  • @joebasham9546
    @joebasham9546 3 роки тому

    //My posting of the 'switch' code, using 'if' statement
    import java.util.Scanner;
    public class ifPlay {
    public static void main(String[] args) {
    System.out.println("What is your name?");
    Scanner scanner = new Scanner(System.in);
    String name = scanner.nextLine();
    String myName = "Joe";
    String herName = "Carol";
    if(name.compareTo(myName) == 0) {
    System.out.println("Welcome");
    }else if(name.compareTo(herName) == 0) {
    System.out.println("Go Away");
    }else {System.out.println("Try again");
    }
    scanner.close();
    }
    }

  • @arturus4750
    @arturus4750 4 роки тому

    Ay My Man squadW

  • @master4755
    @master4755 2 роки тому

    Scanner scanner = new Scanner (System.in);
    String name = scanner.nextLine();
    If (name.equals("Caleb") || name.equals("Clare") ) {
    System.out.println("Go away");
    }
    Else {
    System.out.println("Try again later");
    }

  • @naimilterdincer6141
    @naimilterdincer6141 4 роки тому

    No "break" is needed in the default case, as it is always the last statement in the switch. (y)

  • @herveydesign6931
    @herveydesign6931 4 роки тому

    import java.util.Scanner;
    public class tutoriall {
    public static void main(String[] args) {
    System.out.println("What's your name");
    Scanner scanner = new Scanner(System.in);
    String name = scanner.nextLine();
    if(name.equals("FirtsName") || name.equals("SecondName"))
    {
    System.out.println("Go away!");
    } else
    {
    System.out.println("Try later!");
    }
    }
    }

  • @Moooe-xr3gj
    @Moooe-xr3gj 4 роки тому +1

    import java.util.Scanner;
    public class Java{
    public static void main (String [] args){
    System.out.println("Whats your name?");
    Scanner scanner = new Scanner(System.in);
    String name = scanner.nextLine();
    if(name.toLowerCase().equals("mohammed")){
    System.out.println("Welcome");
    }
    else if(name.equals("Claire")){
    System.out.println("go away");
    }
    else if(name.toLowerCase().equals("claire")){
    System.out.println("Nice try, go away");
    }
    else{
    System.out.println("eh");
    }
    }
    }

  • @youtubeexpert2441
    @youtubeexpert2441 4 роки тому

    if (name.equals("caleb")) {
    sysout "welcome"; // too lazy to write it down fully.. you know what i mean!
    } else if (name.equals( "clare")) {
    sysout "go away";
    } else {
    sysout "try again later";
    }

  • @nathanmaguire1380
    @nathanmaguire1380 5 років тому

    import java.util.Scanner;
    public class User {
    public static void main (String[] args){
    Scanner mainScanner = new Scanner(System.in);
    System.out.println("What is your name?");
    String name = mainScanner.nextLine();
    if (name.toLowerCase().equals("caleb") || name.toLowerCase().equals("clare")){
    System.out.println("Go away");
    }
    else {
    System.out.println("Welcome!");
    }
    }
    }

  • @CrazyChaosClara
    @CrazyChaosClara 4 роки тому

    I will never allow anyone to call me Clare again! :D :D

  • @lodashnotebook5390
    @lodashnotebook5390 5 років тому +1

    1 Caleb disliked this video LOL! :D

  • @tristancodingaccount2557
    @tristancodingaccount2557 2 роки тому

    Bro has beef with the name Clare

  • @akashshah3356
    @akashshah3356 5 років тому

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

    Scanner scanner = new Scanner(System.in);

    System.out.println(" Whats your name?");
    String name = scanner.nextLine();

    if (name.equals("Akash")) {
    System.out.println(" Hi " + name + " Welcome to Java ");

    } else if (name.equals("Sunny")) {
    System.out.println( " Hi " + name + " Welcome to Java ");

    } else {
    System.out.println(" Welcome to Hell");
    }


    }
    }

  • @yayl661
    @yayl661 4 роки тому

    public class hmm{
    public static void main(String[] args){
    method();
    }
    private void method(){
    Scanner sc = new Scanner(System.in);
    String name = sc.next().toLowerCase();
    if(name.equals("claire") || name.equals("caleb")){
    System.out.println("Sorry, you're not allowed entrance, goodbye!");
    }else{
    System.out.println("Try again :)");
    method();
    }
    }
    }

  • @侍フルーツポンチ-i8p
    @侍フルーツポンチ-i8p 4 роки тому

    import java.util.Scanner;
    public class CalebClaire_if {
    public static void main(String[] args) {
    System.out.println("What is your name?");
    Scanner sc = new Scanner (System.in);
    String name = sc.nextLine();
    if (name.toLowerCase().equals("caleb") || name.toLowerCase().equals("claire")) {
    System.out.println("Go away.");
    return;
    }
    else {
    System.out.println("Welcome!");
    }
    System.out.println("Have a nice day, " + name + "!");
    }
    }

  • @healer180
    @healer180 4 роки тому

    is claire your ex? did she hurt you during the break up?

  • @jaybergonia4861
    @jaybergonia4861 5 років тому

    Please do a Tutorial for Java FX
    And please can you use IntelliJidea
    Because I can use a bunch of ad on there including a GUI editor😁😁😁

  • @LayzoEffiart
    @LayzoEffiart 4 роки тому

    Yanderedev disliked this video

  • @a1phaangel16
    @a1phaangel16 5 років тому

    Pramp. (*-ω-)

  • @henrivalencia21
    @henrivalencia21 5 років тому

    if ("Caleb" == name || "Clare" == name) {
    sout("Go away");
    } else {
    sout("Try again later");
    }

  • @faaz.mohammed
    @faaz.mohammed Рік тому

    import java.util.Scanner;
    public class MySweetPtogram {
    public static void main(String[] args) { //method
    System.out.println("What's your name?");

    Scanner scanner = new Scanner(System.in);
    String name = scanner.nextLine();

    if (name.equals("Caleb")|| name.equals("Clare"))
    {
    System.out.println("Go away");
    }


    else
    {
    System.out.println("Try again later");
    }
    }
    }

  • @joeloswin.j336
    @joeloswin.j336 Рік тому

    import java.util.Scanner;
    public class exercise
    {
    public static void main(String[] args)
    {
    System.out.println("Please enter your name : ");
    String Name;
    Scanner scan = new Scanner(System.in);
    Name = scan.nextLine();

    if(Name.equals("Caleb"))
    {
    System.out.println("Welcome my man");
    }else if(Name.equals("Claire"))
    {
    System.out.println("Go away");
    }else
    {
    System.out.println("Try again Later");
    }
    }
    }