So I have been working on this project for quite some time and I can't figure out why I keep getting an "Illegal Start of Expression" error. I tried moving the variables above the main method and that only returned the same error but instead of the error occuring at line 14, it occurs at the start of the next method(applet). Any help would be greatly appreciated! I'm sure it's just some stupid formatting error...

package superhangman;

import java.applet.Applet;
import java.awt.*;
import java.awt.event.*;
import java.util.Random;


public abstract class SuperHangman extends Applet implements ActionListener {
    public static void main(String[] args){



    static final int LOSE = 5;
    private int errors;
    private String message;
    private String information;
    private String rword;
    private StringBuffer gword;
    private Button bReStart;
    private Button bGo;
    private TextField tfLetter;
    private Font fnt;




       public void applet() {
        fnt = new Font("MonoSpaced", 0 ,12);
            setFont(fnt);
        tfLetter = new TextField();     
        bReStart = new Button("Restart");
        bGo = new Button("Go");

        add(bReStart);
        add(bGo);
        add(new Label("Guess a Letter"));
        add(tfLetter);

        bReStart.addActionListener(this);
        bGo.addActionListener(this);

        startgame();

    }   

Inline Code Example Here`

  1. Your attribute declarations (lines 14-23) should be outside any method (now they are in your main method, move them out).
  2. You've put your applet() method (lines 28-43) inside your main method, move it outside of your main.
  3. You miss a curly ending brace for your main and applet method.

Thanks tux4life! There are still a few more problems with my code but I think I can figure them out now!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.