Default case not working in a switch statement

I get a run-time error when i input other flavor than the three listed in the code.
Any comments and suggestions are welcomed.
import java.util.Scanner;
public class EnumSwitchDemo
     enum Flavor {VANILLA, CHOCOLATE, STRAWBERRY};
     public static void main(String[] args)
          Flavor favorite = null;
          Scanner keyboard = new Scanner(System.in);
          System.out.println("What is your favorite flavor? ");
          String answer = keyboard.next();
          answer = answer.toUpperCase();
          favorite = Flavor.valueOf(answer);          
          switch(favorite)
               case VANILLA:
                    System.out.println("Classic");
                    break;
               case CHOCOLATE:
                    System.out.println("Rich");
                    break;
               case STRAWBERRY:
                    System.out.println("Tasty");
                    break;
               default:
                    System.out.println("Sorry, Flavor unavailable");
                    break;
}

Yes, the static valueOf method of an Enum type throws an IllegalArgumentException, if the name is not defined, I think. So the problem is not the switch statement.
Btw, normally you don't need switch statements with enums, since you can define methods in enums.
-Puce

Similar Messages

  • IPhone 4, 16 GB. After upgrading to iOS 7, despite having 10 GB free, the phone says No storage available. Tried a soft reset, tried restore as well. Still not working. iCloud is switched off.

    My wife has an iPhone 4, 16 GB. After upgrading to iOS 7, despite having 10 GB free, the phone says No storage available. Tried a soft reset, tried restore as well. Still not working. iCloud is switched off.
    Please help.. This has become a pain.. and of course theres no way to go back to iOS 6.

    Make sure you have the Latest Version of iTunes (v11.1.5) Installed on your computer
    iTunes free download from www.itunes.com/download
    Then... Restore as New (not backup) and Re-Sync your Content.
    Restoring  >  http://support.apple.com/kb/HT1414
    SYNCING with iTunes >  http://support.apple.com/kb/HT1386

  • Smart case not working. Ipad Air 2 8.1.3

    Hi,
    I just bought a new smart case for Ipad Air 2. I notice that the case not working (open,close cover nothing happens). General setting doesn't have the turn on/off (or lock/unlock or smt like that) under auto lock settings. Anyone has the solution ?
    Thanks

    Thanks SergZak  JimHdk
    I will bring my stuffs to the Apple store and tell them to check. However, is there any chance that problem caused by a screen protector ?! I also bought one that made by shatter resistant glass and that's thicker than other. May be that reduce the sensor sensibility?   

  • Smart scan not working with Insert Select statements

    We have observed that smart scan is not working with insert select statements but works when select statements are execute alone.
    Can you please help us to explain this behavior?

    There is a specific exadata forum - you would do better to post the question there: Exadata
    I can't give you a definitive answer, but it's possible that this is simply a known limitation similar to the way that "Create table as select" won't run the select statement the same way as the basic select if it involves a distributed query.
    Regards
    Jonathan Lewis

  • Defaulting Rules Not Working for Repair Orders in OM?

    Hi,
    Defaulting Rules have been setup for return line & standard line based on few conditions and it is working fine if we create a sales order directly from OM (Manual SO)?
    But in our project we are using  Depot Repair(Repair Orders), we tried to create a service request and then converted to a sales order here defaulting rules not working for repair orders?
    Please help me to solve this issue ASAP.
    Thanks,
    Kishor

    Hi,
    You have like this:
    1. Price list
    2.OE_DEFAULT_PVT.Get_SOB_Currency_Code
    You have to make
    1. XXOE_DEFAULT_PVT.custom_code
    2. Price list
    3.OE_DEFAULT_PVT.Get_SOB_Currency_Code
    Did you made own custom code to pick currency?
    Regards,
    Luko

  • After last update the split keyboard option is not working and side switch button option works opposite for mute and rotation lock

    After last update the split keyboard option is not working and side switch button option works opposite for mute and rotation lock.

    Hi
    A long story about your issue... I think the reason of this is why you have deleted some registry keys. If you delete something in the Windows registry you should really know what you do. You can damage the complete Windows system!
    So I think this is the reason why the keyboard doesnt anymore.
    In the user manual I have founded that the CD-ROM booting option is only available with optional optical disk drive.
    So for me it sounds like that your USB CD drive is not compatible to the notebook

  • Break statement does not work outside of switch or loop?

    I was just messing around in Xcode and I discovered that, when I tried to use the break statement to exit a block of code, I got an error ("break statement not within loop or switch"). I thought the break statement was supposed to be able to be used to exit any block of code at any time, so I opened my Mac OS X Programming book by Wrox (a bit outdated, uses older version of Xcode/Interface Builder, but applicable enough), and the book confirmed that I should be able to use the break statement within any block of code, not just switch/case construction and loops. I assume something has changed in the newer version of Xcode since this book has been published, but I'm curious, so can anyone explain this to me? Thanks!

    Yeah, that seems to be the case, and that's the only way I've ever used "break," but I did think it could be used to exit any block of code, especially having read it in the book I have. The book is Mac OS X Programming by Wrox, and on page 175 in the "The C Language" chapter, it says:
    "break" is not only useful for "switch" and "while" statements; it can actually be used anytime you want to escape a block of code enclosed in braces. Execution is immediately transferred to the closing brace, and continues from there."
    Anyways, I guess it is possible that in some older standard of C the "break" statement was allowed in these cases, since I can't imagine the book being out and out wrong, but you're right, it certainly seems to be -- interesting...

  • Dock not working; command-tab switch between programs not working

    The Dock does not work. I have restarted (although the computer will not restart under "Restart", getting stuck at the last part, and needs to be restarted manually). When I change Dock preferences it reverts back to default settings. If I am lucky, the dock will appear and then disappear (poof) without having functioned.
    The command tab function for switching between programs stopped working also.
    The individual programs work, but I have to go to recent items to switch programs.
    Further, I have two Previews open (with different documents in each) even though I have only one Preview program.
    A whole lot of bizarre things that may be connected? I would appreciate any help.

    You could try removing the .plist file again, but this time, try also removing the com.apple.dock.db file. Then log out and log in again.
    Also, it seems as if many people are having similar problems. See [this thread|http://discussions.apple.com/thread.jspa?messageID=9126119].
    So, does the problem persist with another user account?
    If it were my machine, the next thing I'd try is downloading the combo updater from Apple's website and reinstalling it. 10.5.6 is available [here|http://support.apple.com/downloads/MacOS_X_10-5-6_ComboUpdate].

  • Ping to Switch in DMZ not working from Edge Switch

    Hi Everyone,
    Below is my home Lab setup
    Sw1----trunk ----ospf  sw2-------direct conenction to ASA------DMZ  ------SW3 -------
    Switch3 has SVI IP 192.168.69.1
    I can ping the IP 169.168.69.1 from sw2 as this has default static route to ASA outside interface IP address.
    But i can not ping IP 192.168.69.1 from SW1 need to why ?
    is this default behaviour?
    On switch 1 i add the static route 192.168.69.0 255.255.255.0 192.168.11.1
    Where 192.168.11.1  is interface IP of Sw2 which has direct connection to ASA outside Interface IP ---192.168.11.2.
    Also i define Loopback IP 192.167.77.1  on Sw3.
    This IP i can ping from Sw1  but IP 192.168.69.1 i can not ping.
    I define below static route of Sw1
    ip route 192.168.77.0 255.255.255.0 192.168.10.2
    where 10.2 is vlan 10 IP  on Sw2.
    Thanks
    Mahesh
    Message was edited by: mahesh parmar

    Hi jouni,
    yesterday i already tried with gateway IP of 192.168.10.2  it did  not work then i used 11.1 as gateway same issue.
    Today i tried again same thing.
    3550SMIA(config)#ip route 192.168.69.0 255.255.255.0 192.168.10.2
    3550SMIA(config)#end
    3550SMIA#ping 192.168.69.1
    Type escape sequence to abort.
    Sending 5, 100-byte ICMP Echos to 192.168.69.1, timeout is 2 seconds:
    Success rate is 0 percent (0/5)
    3550SMIA#
    here is sh ip route
    3550SMIA# sh ip route
    Codes: C - connected, S - static, R - RIP, M - mobile, B - BGP
           D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
           N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
           E1 - OSPF external type 1, E2 - OSPF external type 2
           i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2
           ia - IS-IS inter area, * - candidate default, U - per-user static route
           o - ODR, P - periodic downloaded static route
    Gateway of last resort is 192.168.5.3 to network 0.0.0.0
         100.0.0.0/32 is subnetted, 1 subnets
    O       100.100.100.100 [110/3] via 192.168.5.3, 5d02h, FastEthernet0/11
         3.0.0.0/8 is variably subnetted, 2 subnets, 2 masks
    O       3.3.3.3/32 [110/2] via 192.168.5.3, 5d02h, FastEthernet0/11
    C       3.4.4.0/24 is directly connected, Loopback0
    C    192.168.30.0/24 is directly connected, Vlan30
         64.0.0.0/32 is subnetted, 1 subnets
    O E2    64.59.135.150 [110/300] via 192.168.5.3, 5d02h, FastEthernet0/11
    S    192.168.77.0/24 [1/0] via 192.168.10.2
    C    192.168.10.0/24 is directly connected, Vlan10
         172.31.0.0/24 is subnetted, 4 subnets
    O E2    172.31.3.0 [110/300] via 192.168.5.3, 5d02h, FastEthernet0/11
    O E2    172.31.2.0 [110/300] via 192.168.5.3, 5d02h, FastEthernet0/11
    O E2    172.31.1.0 [110/300] via 192.168.5.3, 5d02h, FastEthernet0/11
    O E2    172.31.0.0 [110/300] via 192.168.5.3, 5d02h, FastEthernet0/11
    O    192.168.11.0/24 [110/3] via 192.168.5.3, 5d02h, FastEthernet0/11
    O    192.168.98.0/24 [110/2] via 192.168.99.1, 5d02h, FastEthernet0/8
    C    192.168.99.0/24 is directly connected, FastEthernet0/8
    C    192.168.20.0/24 is directly connected, Vlan20
         192.168.5.0/31 is subnetted, 1 subnets
    C       192.168.5.2 is directly connected, FastEthernet0/11
         192.168.6.0/31 is subnetted, 1 subnets
    O       192.168.6.2 [110/2] via 192.168.5.3, 5d02h, FastEthernet0/11
    S    192.168.69.0/24 [1/0] via 192.168.10.2
    O*E2 0.0.0.0/0 [110/1] via 192.168.5.3, 5d02h, FastEthernet0/11
    Thanks
    MAhesh

  • [SOLVED] GRUB DEFAULT settings not working

    Hi to everyone,
    after a system update the default settings for grub is not working. It still booting automatically to first occurrence...
    This is what grub-customizer sees:
    so I can imagine everything is set ok. What could I check more?
    Last edited by Tid91 (2014-03-07 17:58:27)

    Hi,
    Check /boot/grub/grub.cfg, and in your case you should set:
    set default="4"
    Take in mind it's zero-based.
    Beware, you should be doing this modifying /etc/default/grub and rebuilding your config file with grub-mkconfig; see the wiki for more details on how to do it.

  • ACL not working on 3750 Switch Stack on a trunk port

    I cannot figure out why the ACL is not working on a 3750 running 12.2 (55)SE on a trunk port.  For testing, there is 1 x IP (10.101.15.13) that should be denied to all VLANs on the trunk.  I have tried standard and extended list, but neither seem to work.
    What am I doing wrong?
    Access-List:
    Standard IP access list 10
        10 deny   10.101.15.13 log
        20 permit any log
    Access-List Interface:
    interface GigabitEthernet7/0/10
     description ESX Trunk
     switchport trunk encapsulation dot1q
     switchport trunk allowed vlan 1,2,60-63
     switchport mode trunk
     ip access-group 10 in
    Mac-Address on the Switch Port:
    63    0050.569a.6d9f    DYNAMIC     Gi7/0/10
    Windows Machine MAC:
    Description . . . . . . . . . . . : vmxnet3 Ethernet Adapter #4
    Physical Address. . . . . . . . . : 00-50-56-9A-6D-9F
    Windows Connection (which should be denied):
     TCP    10.20.63.4:3389        10.101.15.13:21289     ESTABLISHED     InHost

    PACL only apply to an L2 interface.  On an L2 interface the only direction that can be applied is INBOUND.  On an L3 interface INBOUND or OUTBOUND can be specified.
    In any case, I have worked around the issue by applying VACLs. Marking this as resolved.

  • Cross-reference does not work inside the object states

    Hi All,
    I use InDesign CS5.5. I have four pages document. first three page has full for text and the fourth page has multi-state object. I am trying to insert the cross reference from the third page to the multi-state object (fourth multi-state object). when I export to SWF and click the cross-reference it does not got to the fourth state, but it goes to only on the first state. can any one help me how to add the cross-reference?
    I have tried on the other way. i have inserted the text anchor on the fourth multi-state object and tried to add cross-reference, still it does not work.
    am i doing something wrong or InDesign does not have this feature.
    please help.
    thanks.
    Regards
    Ramji V K

    @Ramji V K – Do we have a "terminology problem" here?
    Do you really mean a "Cross-Reference" or do you try to control the MultiStateObject (MSO) by a "Button" that does not work propperly?
    I did not do anything with the "Cross-Reference" feature yet, so I might be on the wrong trail…
    Uwe

  • Mini player does not work, can only switch playlists by closing and restarting iTunes

    For the last few versions of iTunes, my mini player does not work, only choices are large window and larger window.  Also, if I am listening to a playlist and hit the pause button, then switch to another playlist, the old playlist keeps playing when I hit play.  The only way I can figure out to switch playlists is to quit and relaunch iTunes.

    try rebooting the ipad
    you know holding down the on button and the home button until the slider comes
    and turn it off and start it up again

  • My iphone 3gs is not working properly, when switched on it says 'Update Completed' as though it has just been updated. On the next screen it says to 'Connect to iTunes'. It doesn't, however, connect to iTunes and more often than not just resets itself.

    My iPhone 3gs is not working properly and hasn't been since about September of last year. When switched on (Quite often it won't even turn on) it says 'Update Completed' as though it has just been updated. On the next screen it says to 'Connect to iTunes'. It doesn't, however, connect to iTunes and just resets itself over and over until power is gone. Occasionally after switching on and off a few times it functions normally for a few hours and some times even a couple of days but eventually always turns itself off and goes back to the 'Update Completed' screen. Does anyone know what might be causing this and/or a way of fixing it?

    Morning JordenR,
    Thanks for using Apple Support Communities.
    You can resolve many restore issues using the troubleshooting steps documented here.
    For more information on this, take a look at this article:
    iOS: Resolving update and restore alert messages
    http://support.apple.com/kb/ts1275
    Best of luck,
    Mario

  • Flash player is not working whenever I switch to airport connection

    The flash player is not working in both Safari and firefox, when I switch the internet connection to the airport (WiFi), but the Ethernet connection is working fine with flash player.
    reinstall of Mac os x 10.6 --> not working
    repair disk and permission from DVD ---> not working
    I have now. First I ran repair permissions with Disk utility, got some promising repair stuff like
    18.4.2008 14.52.55 Disk Utility282 User differs on "Library/Internet Plug-Ins/Flash Player.plugin/Contents/Resources/Flash Player.rsrc", should be 0,
    user is 501.
    Any further ideas? Or tips on how I could try debugging this? Console gives me squat.

    Crashes or other problems with certain multimedia content in Firefox (such as Youtube videos and Flash animations or games) can often be resolved by performing the steps in these Knowledge Base articles:
    * [[Flash Plugin - Keep it up to date and troubleshoot problems]]
    * [[Flash 11.3 crashes]]
    * [[Flash 11.3 doesn't load video in Firefox]]
    On Windows Vista and above, you can disable Flash protected mode by following the instructions on these pages:
    * http://forums.adobe.com/thread/1018071#TemporaryWorkaround
    * http://kb.mozillazine.org/Flash#Disabling_Protected_Mode_in_Flash_11.3
    (See [http://blogs.adobe.com/asset/2012/06/inside-flash-player-protected-mode-for-firefox.html this Adobe blog post] for technical details about Flash protected mode.)
    Please tell us if this helped!

Maybe you are looking for

  • Need Working Drivers for Macbook 2,1 running Windows 8 (64-bit) using Boot Camp 5 (Mountain Lion)

    So I found my old Macbook 2,1 on Leopard the other day and decided to make it my dedicated Windows computer. I wanted to run Windows 8 on it, so I figured out I needed Boot Camp 5. Then I realized Boot Camp 5 only runs on Mountain Lion, so I went tho

  • Radio Buttons & Repeat Groups

    Seems like it should be easy, but I've not been able to figure it out. I'm pulling a list of records from a mySql DB, populate those within a Form/Table so that a user can select one of the records via a Radio Button. Upon Submit, I'd like to be able

  • Account number find, help

    I still cant find my account number, I have requested one and 14 days later still nothing, I need to activate Mybt so I can view my bill and get my account number so I can activate my account, I have a plusnet land line and broadband, my wife needs h

  • Export Parent Child Report data

    Hello, Does anyone know if it is possible to export Child - parent report data in one file? Kind regards, Oli

  • In sap plm projects

    hi guru. in sap plm projects is this necessary , to generate the reports,scripts. what is exactly sap plm projects,give some idea briefly.because just recently i got offer for working in sap plm development projects. help me. thanks& regards subhasis