Adblock breaks this site

Java Tutorial Pt.3 of many! - Switch tutorial

Discussion in 'Archives' started by diabl0, Sep 18, 2010.

  1. diabl0

    diabl0 Apprentice
    Banned

    Joined:
    Jul 25, 2008
    Posts:
    902
    Referrals:
    0
    Sythe Gold:
    0
    Java Tutorial Pt.3 of many! - Switch tutorial

    Hey guys, today We will be learning about switches! Exciting huh!

    Okay guys, let's get started. So of course you know the basics, starting out adding your main and etc.

    so to start off, as usual we are going to add under our first line this:
    [​IMG]
    Okay guys, now we have added our main, let's get started with the coding. Now the first thing we are going to want to do is add an interger, so lets make ummm Races (I am sorry this may seem racist, But there is no intention of racism I promise). So under our main let's add:

    [​IMG]
    Okay now we have our race added, lets start the switch. So we are going to add out code to start the switch, then we will list 3 possible choices:

    [​IMG]
    I forgot to say we were going to be working with breaks also. What breaks do is they stop the code after it checks each line. This way the program will not just run through and exit out immediately.

    Now under this code, let's add a default:

    This is just in case the program does not recognize a race, it will go to a default form.

    [​IMG]

    Now, Run the program, it will say you can now speak English. Just change the race number to 2, 3, 4 and see the results.

    I hope you guys have learned alot. :) Thank you for reading, make sure you leave comments.
     
  2. Dr. James

    Dr. James Active Member
    $5 USD Donor New

    Joined:
    Sep 17, 2010
    Posts:
    120
    Referrals:
    0
    Sythe Gold:
    0
    Java Tutorial Pt.3 of many! - Switch tutorial

    Looks like we have a talented Java programmer on Sythe? :p
     
  3. diabl0

    diabl0 Apprentice
    Banned

    Joined:
    Jul 25, 2008
    Posts:
    902
    Referrals:
    0
    Sythe Gold:
    0
    Java Tutorial Pt.3 of many! - Switch tutorial

    Lol thank you :)
     
< World Economy Collapse explained in 3 minutes | The Razer L33T Giveaway >


 
 
Adblock breaks this site