• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Why This Compiler Error?

 
Gary Farms
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When I run the following java program, I get a compiler error saying it expects a ; on the B() statement.
Why this compiler error: Here's the program:
[ Formatted code is often much easier to read and understand. I edited this message to surround code with [code] and [/code] UBB Tags in order to help preserve the code formatting. -ds ]
[ September 26, 2002: Message edited by: Dirk Schreckmann ]
 
Dirk Schreckmann
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It looks like you were trying to define the constructor inside of the main method. You can't do that this way. The constructor for class B belongs outside of any method body.Making sense?
 
Anthony Villanueva
Ranch Hand
Posts: 1055
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The constructor of B() is inside main()
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic