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 :-)

AnalProgrammer2012-02-06T01:32:23Z

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.

Anonymous2017-01-13T04:44:55Z

Freddies Fast Food