21 thoughts on “Learn Java Tutorial for Beginners, Part 9: Switch

  1. I need help on this corse it was going smooth until I typed in text after switch I added the swigly line but (text) just come up incorrect and I looked at yours and at mine and their exancly the same ecept my text is red it says "can't switch value of type string for source level below 1.7. Only convertible int values or enum variables are permitted." Help please

  2. I know that doing a switch statement with String is new. That it used to be reserved only for int, char and double. However, I have heard that if the user has an old version of Java installed on their computer the String switch statement will make your program crash. That better just to be safe and not use String switch statements. Any advice on this issue?

  3. if some one type "Start" than the default case will be execute but want to know how to solve this type of lower or upper case problem on switch statement. thanks in advance

  4. Thanks for the great tutorials:)Actually I've run the exact code that you wrote but got an error: " Cannot switch on a value of type String for source level below 1.7. Only convertible int values or enum variables are permitted " . Is that due to an old version of eclipse?should I upgrade it?

  5. Somehow I downloaded an old version of Eclipse, and it was pointing to Java 1.6, which won't allow switching on String types. So I have the newest version (Juno) now, that fixed it. Here's the error: "Cannot switch on a value of type String. Only int values or enum constants are permitted."

  6. Yes, you can do the following. By the way, programming games is an excellent way to learn programming. That's how I started; I got a job as a developer a year later (sadly not programming games though!!)

    String text = "Hello how are you?";

    if(text.contains("how")) {
    System.out.println("found it.");

  7. Is there a way to only recognize certain words, not the whole string?
    Let's say I'm making a text-based game.
    If you say "Go to the north," it would look for the word "north" and execute a command.
    Thanks in advance!

Leave a Reply

Your email address will not be published. Required fields are marked *