jQuery in Action, 3rd edition
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes SWITCH Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of OCA Java SE 8 Programmer I Study Guide this week in the OCAJP 8 forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "SWITCH" Watch "SWITCH" New topic


Honey Khumalo

Joined: Mar 28, 2008
Posts: 6
What happens if the switch statement tests false?
Anubhav Anand
Ranch Hand

Joined: May 18, 2007
Posts: 341

A switch statement works for a key

For key values you can use int or enum constants(JDK 5.0).

Now, if a key is supplied the switch body is executed. If a case is met then the appropriate action is performed. If no case is tested true then control goes to default statement and it is executed. In case there is no default then switch block is ended without any action.

Hope that helps.

[Should have mentioned this before]
PS. Please don't write subject line in caps as it is considered rude and is like shouting in the forum.
[ April 03, 2008: Message edited by: Anubhav Anand ]
I agree. Here's the link: http://aspose.com/file-tools
subject: SWITCH
jQuery in Action, 3rd edition