Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7032103
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T00:53:27+00:00 2026-05-28T00:53:27+00:00

I am using Neatbeans 7.0 for Java programming. I have written a Switch case

  • 0

I am using Neatbeans 7.0 for Java programming. I have written a Switch case for selection of the program.

switch(menu)
        {
            case 1:
            {
                //stmt
            }
            default:
            {
                //stmt
                return;
            }
        }

I am getting compile time error at switch(menu)

The Error is "strings in switch are not supported in -source 1.6
  (use -source 7 or higher to enable strings in switch)

(Alt-Enter shows hints)” Can any one please help me on this.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T00:53:28+00:00Added an answer on May 28, 2026 at 12:53 am

    I’m assuming here that menu is a string type, though it doesn’t really match your case statements. Allowing the use of strings in switch statements was added in Java 7.

    You can either switch to Java 7 and fix the case so that it checks against a string rather that the integral 1, or convert menu to an integer and check that, such as with Integer.ParseInt(), something like:

    String menu = "1";
    int menuint;
    try {
        menuint = Integer.ParseInt (menu);
    } catch (NumberFormatException e) {
        menuint = -1;
    }
    switch (menuint) {
       :
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have just started with Gui Programming in netbeans (Using the template Java Desktop
I'm programming with Java in Linux using Netbeans 7 and as my program (sometimes)
greetings, today i have started to learn java using netbeans ide. i would like
I'm programming a desktop application in Java using NetBeans . My question is this:
I've inherited a java project that appears to have been developed using the NetBeans
I have a difficult dilemma. I implemented a java application using Netbeans while implementing
I'm pretty new to Perl but have been programming in java for several months
I am using netbeans IDE to develop a GUI for a java program. I
We have a Java EE 5 project developed using Netbeans 6.7.1 with Glassfish v2.1.
Im using NetBeans 7.0.1 on a Mac, Code completion for Java programming is extremely

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.