| Author |
compiler error in the Party.java on page 3
|
Dinesh Kumar Tadepalli
Greenhorn
Joined: Jun 17, 2009
Posts: 15
|
|
when i ran the party.java on page 3 of head first java, the compiler gave an error saying p.add(1) - cannot find symbol.
i also want to know if the letter inside the parenthesis of p.add is number 1 or capital letter I.
I tried both the ways but the compiler lists an error saying "cannot find symbol" and it points at p.add(1)
can anyone help me with this.
dinesh
|
 |
Christophe Verré
Sheriff
Joined: Nov 24, 2005
Posts: 14672
|
|
|
Please post the code. The "p" variable may be out of scope, or not even exist, but it's hard to tell without seeing the code.
|
[My Blog]
All roads lead to JavaRanch
|
 |
Dinesh Kumar Tadepalli
Greenhorn
Joined: Jun 17, 2009
Posts: 15
|
|
Here is the code:
import java.awt.*;
import java.awt.event.*;
class Party{
public void buildInvite(){
Frame f = new Frame();
Label l = new Label("Party at Tim's");
Button b = new Button("You Bet");
Button c = new Button("Shoot me");
Panel p = new Panel();
p.add(1);
}
}
Thanks, waiting for your reply
|
 |
Vijitha Kumara
Bartender
Joined: Mar 24, 2008
Posts: 3670
|
|
It should be,
And please use code tags when posting code.
|
SCJP 5 | SCWCD 5
[How to ask questions] [Twitter]
|
 |
Dinesh Kumar Tadepalli
Greenhorn
Joined: Jun 17, 2009
Posts: 15
|
|
thanks for the correction.
Also, the program is giving other error stating.
" Exception in thread "main" java.lang.NoSuchMethodError: Main "
What should I learn from this?
dinesh
|
 |
Vijitha Kumara
Bartender
Joined: Mar 24, 2008
Posts: 3670
|
|
That's when you try to run the class which does not have a main method (in this case). Java look for a main method with the signature (public static void main(String[] args)) when you try to run a class using "java <classname>".
|
 |
 |
|
|
subject: compiler error in the Party.java on page 3
|
|
|