Results 1 to 6 of 6
  1. #1
    king2be98 is offline Member
    Join Date
    Mar 2010
    Posts
    8
    Rep Power
    0

    Default Converting if to Switch Case.

    Hey guys, just needed a bit of help converting an if statement to a case statement, I've realised that I will need to make further coding easier, or at least more organised.
    Last edited by king2be98; 02-20-2011 at 03:35 PM. Reason: Problem resolved.

  2. #2
    Petr's Avatar
    Petr is offline Senior Member
    Join Date
    Jan 2011
    Location
    Russia
    Posts
    620
    Rep Power
    4

    Default

    Why do you want do this?
    Skype: petrarsentev
    http://TrackStudio.com

  3. #3
    king2be98 is offline Member
    Join Date
    Mar 2010
    Posts
    8
    Rep Power
    0

    Default

    Quote Originally Posted by Petr View Post
    Why do you want do this?
    Well I'm relatively new to java, just know the basics, but it seems like it's easier to do something with cases.

    ie. first case the string = go
    second case string !=go etc.

    Is this not the sensible approach? Should I continue to use if else?

  4. #4
    Petr's Avatar
    Petr is offline Senior Member
    Join Date
    Jan 2011
    Location
    Russia
    Posts
    620
    Rep Power
    4

    Default

    Well You need create special enumerations for this aim and to compare their in switch/case statement.
    Last edited by Petr; 02-20-2011 at 03:45 PM.
    Skype: petrarsentev
    http://TrackStudio.com

  5. #5
    king2be98 is offline Member
    Join Date
    Mar 2010
    Posts
    8
    Rep Power
    0

    Default

    Quote Originally Posted by Petr View Post
    Well You need create special enumerations for this aim and to complete their in case statement.
    Thanks mate, after your initial comment I went back and thought about it and realised you were right. It's easier for me to use if and else.

  6. #6
    Petr's Avatar
    Petr is offline Senior Member
    Join Date
    Jan 2011
    Location
    Russia
    Posts
    620
    Rep Power
    4

    Default

    But it is for experience you will able to use this approach.
    Skype: petrarsentev
    http://TrackStudio.com

Similar Threads

  1. Switch Case statement
    By seanfmglobal in forum New To Java
    Replies: 7
    Last Post: 02-15-2011, 01:18 PM
  2. switch case with integers and strings...
    By JavaComplient in forum New To Java
    Replies: 2
    Last Post: 10-21-2010, 06:52 AM
  3. if else changes to switch-case?
    By noobinoo in forum New To Java
    Replies: 1
    Last Post: 04-23-2010, 05:56 PM
  4. Replies: 2
    Last Post: 02-23-2009, 12:34 AM
  5. Switch Case and Key Events
    By AndrewM16921 in forum New To Java
    Replies: 4
    Last Post: 01-26-2009, 11:20 PM

Posting Permissions

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