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 6705357
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T07:23:40+00:00 2026-05-26T07:23:40+00:00

I am coming from a C background, so I am assuming I have the

  • 0

I am coming from a C background, so I am assuming I have the syntax incorrect.

In the following code;

    public class ButtonListener implements ActionListener {
    public void actionPerformed(ActionEvent e) {

        String jcbValue = (String) jcbIDF.getSelectedItem();
        if (jcbValue.equals("Insert")) {

            String Id = jtfId.getText();
            ArrayList<String> ValueList = new ArrayList<String>();
            String Name = jtfName.getText();
            String GPA = jtfGPA.getText();
            ValueList.add(Name);
            ValueList.add(GPA);
            if (map.containsKey(Id)){
                JOptionPane.showMessageDialog(null, "Key exists!",
                        "Result", JOptionPane.INFORMATION_MESSAGE);
            }   
            else if (!map.containsKey(Id)){

                map.put(Id, ValueList);
                System.out.println(map);

                JOptionPane.showMessageDialog(null, "Record inserted",
                        "Result", JOptionPane.INFORMATION_MESSAGE);
                jtfId.setText("");
                jtfName.setText("");
                jtfGPA.setText("");
            }

        } //terminates insert
        else if (jcbValue.equals("Delete")) {
            String Id = jtfId.getText();
            ArrayList<String> ValueList = new ArrayList<String>();
            String Name = jtfName.getText();
            String GPA = jtfGPA.getText();

            if (map.containsKey(Id)){
            JOptionPane.showMessageDialog(null, "Key exists, deleted!",
                        "Result", JOptionPane.INFORMATION_MESSAGE);
            } else if (!map.contasKey(Id)){      
            System.out.println(map);
            JOptionPane.showMessageDialog(null, "Key Does not exist!",
            }                                                       


        } //terminates delete
        else if (jcbValue.equals("Find")) {
            System.out.println(map);
            JOptionPane.showMessageDialog(null,
                    "Find Selected; But not Implemented", "Result",
                    JOptionPane.INFORMATION_MESSAGE);
        } //terminates find

    }// Terminates actionPerformed Class
}// Terminates ButtonListenerClass

I am getting compile errors saying “} Unexpected on line X, and premature EOF. If I removed the sub IFs that evalute map.containsKey(Id) it compiles and runs fine. Everything I read on the internet says Java is capable of nesting IF statements, so what exactly am I doing wrong?

Thanks for your help!

CJ

  • 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-26T07:23:41+00:00Added an answer on May 26, 2026 at 7:23 am

    This line?

            JOptionPane.showMessageDialog(null, "Key Does not exist!",
            }
    

    Your method call is not closed. I think you meant to do this:

            JOptionPane.showMessageDialog(null, "Key Does not exist!",
                                          "Result", JOptionPane.INFORMATION_MESSAGE);
            }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am coming from C# background and I have hard time figuring out how
Coming from a Perl background, I have to say I prefer cpan Foo::Bar to
Coming from a VB background and being forced to learn C# I have hit
I am coming from CVS background. Currently, I have 2 mercurial repositories developed parallel.
I'm coming from a background in languages like Actionscript 3 where we have a
what is wrong with this code below? The conn_PageDeleted is coming from a background
Coming from a background, I'm familiar with GUI editors that do a poor job
I'm coming from a background in ColdFusion, and finally moving onto something modern, so
When I was learning Java coming from a background of some 20 years of
Coming from a C# background the naming convention for variables and methods are usually

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.