I'm just learning how to program in java. I wrote my first java program, but got an error. Here is my program.
import java.awt.*;
import java.applet.*;
public class me extends Applet
{
public void init ()
{
String AuthorName;
AuthorName = "Steven Spielberg";
}
public void paint (Graphics x)
{
x.drawString (AuthorName,50, 50);
}
}
------------------- END OF PROGRAM ------------------------------
When I compiled it with command "javac <file_name.java >" (ie: javac me.java), it got an error. Error showed:
% javac me.java
me.java:12: cannot find symbol
symbol : variable AuthorName
location: class me
x.drawString (AuthorName,50, 50);
^
1 error
----------------------------------------------------------------------------------
Any help is appreciated. Thank you in advance.
-simon
import java.awt.*;
import java.applet.*;
public class me extends Applet
{
public void init ()
{
String AuthorName;
AuthorName = "Steven Spielberg";
}
public void paint (Graphics x)
{
x.drawString (AuthorName,50, 50);
}
}
------------------- END OF PROGRAM ------------------------------
When I compiled it with command "javac <file_name.java >" (ie: javac me.java), it got an error. Error showed:
% javac me.java
me.java:12: cannot find symbol
symbol : variable AuthorName
location: class me
x.drawString (AuthorName,50, 50);
^
1 error
----------------------------------------------------------------------------------
Any help is appreciated. Thank you in advance.
-simon
Comment