aspose file tools*
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 The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "SWITCH" Watch "SWITCH" New topic
Author

SWITCH

Honey Khumalo
Greenhorn

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 ]
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: SWITCH