Yahoo Answers is shutting down on May 4th, 2021 (Eastern Time) and beginning April 20th, 2021 (Eastern Time) the Yahoo Answers website will be in read-only mode. There will be no changes to other Yahoo properties or services, or your Yahoo account. You can find more information about the Yahoo Answers shutdown and how to download your data on this help page.

one error in Java code Please help?

Hi could someone please help me with this code I have one error. The program creates an applet related to Fast-Food Sandwiches created at Freddie's fast food:

import java.awt.*;

import java.applet.*;

import java.awt.event.*;

public class Freddie extends Applet implements ItemListener

{

public void init()

{

//Construct Components

Label sandwichPromptLabel = new Label("sandwich");

Label sandwichInputField = new TextField("Input");

Label sizePromptLabel = new Label("Size");

CheckboxGroup sandwichGroup = new CheckboxGroup();

Checkbox catsupBox = new Checkbox("catsup",false,sandwichGroup);

Checkbox mustardBox = new Checkbox("mustard",false,sandwichGroup);

Checkbox picklesBox = new Checkbox("pickles",false,sandwichGroup);

Checkbox sizeGroupBox = new Checkbox("sizeGroup",true,sandwichGroup);

Checkbox smallBox = new Checkbox("small",false,sandwichGroup);

Checkbox mediumBox = new Checkbox("medium",false,sandwichGroup);

Checkbox largeBox = new Checkbox("large",false,sandwichGroup);

public void init()

{

setBackground(red);

add(promptLabel);

add(inputField);

add(size);

add(catsup);

add(mustard);

add(pickles);

add(sizeGroup);

add(small);

add(medium);

add(large);

public void itemStateChanged(ItemEvent choice)

{

}

};};};

This is the Error:

C:\Course Technology\59850d\Chapter 04\Freddie.java:35: illegal start of expression

public void init()

^

1 error

Thank You :-)

2 Answers

Relevance
  • 9 years ago
    Favorite Answer

    public void init()

    public void init()

    You cannot have two methods with the same signature. That is name, and number of and type of parameters matching.

    This

    };};};

    should be

    }}}

    Have fun.

  • Anonymous
    4 years ago

    Freddies Fast Food

Still have questions? Get your answers by asking now.