File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

compiler error in the Party.java on page 3

 
Dinesh Kumar Tadepalli
Greenhorn
Posts: 15
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Dinesh Kumar Tadepalli
Greenhorn
Posts: 15
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3908
9
Chrome Fedora Hibernate
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

It should be,


And please use code tags when posting code.
 
Dinesh Kumar Tadepalli
Greenhorn
Posts: 15
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3908
9
Chrome Fedora Hibernate
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Also, the program is giving other error stating. " Exception in thread "main" java.lang.NoSuchMethodError: Main "


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>".
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic