Results 1 to 6 of 6

Thread: case statement

  1. #1
    skiing is offline Member
    Join Date
    Nov 2008
    Posts
    15
    Rep Power
    0

    Default case statement

    I have a question in reguards to case statements in java
    if you use case and it is not one of the one's listed in the case statements and their is not a default statement what does java do?

  2. #2
    fxRichard is offline Member
    Join Date
    Dec 2008
    Posts
    64
    Rep Power
    0

    Default

    Does nothing then

  3. #3
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,315
    Blog Entries
    1
    Rep Power
    26

    Default

    Often when I have a question like this, I write a small test program and see what happens. You might want to try something like this yourself as doing so will teach you more than the answer to your question.

  4. #4
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,371
    Blog Entries
    1
    Rep Power
    20

    Default

    Any case statement(s) execute IF AND ONLY IF a condition is satisfied. If not looking into the default statement(s). If no any action take place there, nothing to do, just leave the switch-case code block and entered to the next.

    Best thing to clear up this is, as Fubarable says workout a simple application and see.

  5. #5
    ron87 is offline Member
    Join Date
    Mar 2009
    Posts
    52
    Rep Power
    0

    Default

    write a small piece of code and test it..

  6. #6
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,315
    Blog Entries
    1
    Rep Power
    26

    Default

    Quote Originally Posted by ron87 View Post
    write a small piece of code and test it..
    Now why didn't I think of that?

Similar Threads

  1. SashForm doesn't seem to work in this case
    By Rodrigo Braz in forum SWT / JFace
    Replies: 0
    Last Post: 03-22-2009, 11:39 AM
  2. Replies: 2
    Last Post: 02-23-2009, 01:34 AM
  3. Case Based Reasoning
    By kbyrne in forum Advanced Java
    Replies: 4
    Last Post: 04-12-2008, 09:51 PM
  4. Statement or Prepared Statement ?
    By paty in forum JDBC
    Replies: 3
    Last Post: 08-01-2007, 05:45 PM
  5. Can I set a range in case statement?
    By christina in forum New To Java
    Replies: 1
    Last Post: 07-25-2007, 09:41 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
  •