11. public class Test {
12. public enum Dogs {collie, harrier, shepherd};
13. public static void main(String [] args) {
14. Dogs myDog = Dogs.shepherd;
15. switch (myDog) {
16. case collie:
17. System.out.print(”collie “);
18. case default:
19. System.out.print(”retriever “);
20. case harrier:
21. System.out.print(”harrier “);
22. }
23. }
24. }
那里错了呢??
------解决方案--------------------
答:case default:
改为:default:
------解决方案--------------------
System.out.print(”collie “);
18. case default:
19. System.out.print(”retriever “);
去掉default