aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes behavior of switch statement with enums 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 "behavior of switch statement with enums" Watch "behavior of switch statement with enums" New topic
Author

behavior of switch statement with enums

Jack McLaren
Greenhorn

Joined: Jun 17, 2013
Posts: 13


it prints "sunday"

why not

"default
final float
sunday"


I AM THE LAW.
Stuart A. Burkett
Ranch Hand

Joined: May 30, 2012
Posts: 679
jobless jack wrote:
it prints "sunday"

why not

"default
final float
sunday"

Time for you to get to know the Java Language Specification. See section 14.11.
Matthew Brown
Bartender

Joined: Apr 06, 2010
Posts: 4366
    
    8

The position of the default statement doesn't matter - it's still only executed if none of the case conditions match (as your example shows).

One reason why it's a really bad idea to put it anywhere other than at the end of the switch statement.

Jack McLaren
Greenhorn

Joined: Jun 17, 2013
Posts: 13

Matthew Brown wrote:The position of the default statement doesn't matter - it's still only executed if none of the case conditions match (as your example shows).

One reason why it's a really bad idea to put it anywhere other than at the end of the switch statement.



thank you

now i understand, how this program works.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: behavior of switch statement with enums