Results 1 to 3 of 3
- 11-16-2012, 04:51 AM #1
Member
- Join Date
- Nov 2012
- Posts
- 4
- Rep Power
- 0
"Illegal start of expression", What does this mean?
Hey guys,
I was writing code for my Hello World HTML Applet and when I compiled it in my cmd, it gave me the errors...
HelloWorld.java:8: error: illegal start of expression
private Font a_Font
HelloWorld.java:11: error: illegal start of expression
public void init()
HelloWorld.java:11: error: illegal start of expression
public void init()
HelloWorld.java:11: error: illegal start of expression
public void ()
Java Code:import java.applet.*; import java.awt.*; public class HelloWorld extends Applet { public void paint (Graphics g) { private Font a_Font; g.setColor (Color.blue); public void init() { a_Font = new Font("Helvetica", Font.BOLD, 48); setFont(a_Font); setBackground(Color.yellow); setForeground(Color.blue); } g.drawString("Hello World", 50, 25); g.setColor(Color.red); g.drawRect (5,8,49,29); } }
-
Re: "Illegal start of expression", What does this mean?
You've got code either in the wrong place or written incorrectly. Already I see you've got methods nested inside of methods, you're declaring variables as private inside of methods which is illegal....
The biggest mistake I see is that you have more than one of these errors present which mean that you are coding wrong. You need to start with the barest skeleton of code, and first make sure that it compiles. Then when adding code if you're not using an IDE you must compile often, usually after adding each line or two of code, and don't add any new code until the current code compiles well.
- 11-16-2012, 05:28 AM #3
Similar Threads
-
Problem witch "Illegal start of expression"
By thyks in forum New To JavaReplies: 19Last Post: 06-12-2012, 11:06 AM -
Regular expression for alphanumeric characters containing space ,"_" and "-"
By dpkcv in forum Advanced JavaReplies: 2Last Post: 10-03-2011, 07:22 PM -
"illegal start of expression" killing me help please.
By Taszk in forum New To JavaReplies: 4Last Post: 05-27-2011, 09:21 AM -
Error: "Illegal start of expression"
By mokitooo_1994 in forum New To JavaReplies: 5Last Post: 05-12-2011, 10:42 PM -
"illegal start of expression"
By 3RDofApril in forum AWT / SwingReplies: 2Last Post: 11-04-2010, 02:39 AM
Bookmarks