Thread: Using switch statement

Page 1 of 3 123 LastLast
Results 1 to 10 of 29
  1. #1 Using switch statement [BEGGINERS!] 
    Banned

    Join Date
    May 2007
    Posts
    2,690
    Thanks given
    115
    Thanks received
    45
    Rep Power
    0
    My Project: [Only registered and activated users can see links. ]

    Ok I'm going to explain how to use switch statement.

    Switch statement will replace all the annoying if statements.

    The method without switch statement would look like

    Code:
    public void Something() {
    if(Other == 1)
    MakeThing1();
    else if(Other == 2)
    MakeThing2();
    }
    Now we can switch it and shorten that method to

    Code:
    public void Something() {
    switch(Other)
    
    case 1:
    MakeThing1();
    break;
    case 2:
    MakeThing2();
    break;
    }
    Thanks, hope it helped..

    This is simple but effective..
     

  2. #2  
    Banned

    Join Date
    Feb 2007
    Posts
    1,578
    Thanks given
    16
    Thanks received
    20
    Rep Power
    0
    Thanks for this ivan rep if i dont need to spread
     

  3. #3  
    Registered Member

    Join Date
    Aug 2007
    Posts
    2,395
    Thanks given
    2
    Thanks received
    63
    Rep Power
    558
    Looks good, but it's quite simple ?
    Good for noobs who don't even know java


    Jonas
    [Only registered and activated users can see links. ]
     

  4. #4  
    Registered Member


    Join Date
    Jul 2007
    Posts
    4,133
    Thanks given
    789
    Thanks received
    2,716
    Rep Power
    5000
    nice rep + thanks for the link you gave me btw "
     

  5. #5  
    Banned

    Join Date
    May 2007
    Posts
    2,690
    Thanks given
    115
    Thanks received
    45
    Rep Power
    0
    Well its for begginers
     

  6. #6  
    Simon
    Guest
    /sticky Corey + Ivan
     

  7. #7  
    To live
    Guest
    I'm interested how you are writing cases without a break; statement, is this entire tutorial in purpose to show how your code will fail?
     

  8. #8  
    Simon
    Guest
    Quote Originally Posted by To live View Post
    I'm interested how you are writing cases without a brake; statement, is this entire tutorial in purpose to show how your code will fail?
    I'm interested why you won't shut the **** up and stop criticising.
     

  9. #9  
    Stanyer
    Guest
    l2codeconvention.
     

  10. #10  
    Registered Member
    Join Date
    Mar 2008
    Posts
    61
    Thanks given
    1
    Thanks received
    0
    Rep Power
    1
    holy ****, you explained in like too words good job!!!
     

Page 1 of 3 123 LastLast

Thread Information
Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)


User Tag List

Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •