Specifications

Sun Services
Java™ Programming Language
Module 7, slide 21 of 44
Copyright 2005 Sun Microsystems, Inc. All Rights Reserved. Sun Services, Revision F
The New Enumerated Type
16 public String getSuitName() {
17 String name = ““;
18 switch ( suit ) {
19 case SPADES:
20 name = “Spades”;
21 break;
22 case HEARTS:
23 name = “Hearts”;
24 break;
25 case CLUBS:
26 name = “Clubs”;
27 break;
28 case DIAMONDS:
29 name = “Diamonds”;
30 break;
31 default:
32 // No need for error checking as the Suit
33 // enum is finite.
34 }
35 return name;
36 }