This week's book giveaway is in the Performance forum.
We're giving away four copies of The Java Performance Companion and have Charlie Hunt, Monica Beckwith, Poonam Parhar, & Bengt Rutisson on-line!
See this thread for details.
Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

SCJP Difficulty

 
Shreyansh Singh
Greenhorn
Posts: 2
C++ Java Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
While running the following Program on NetBeans ,I am getting the following Error:

D:\JAVA\Java$Program\src\java$program\SCJP_Richard_Raposa_Pg_189_Buffalo.java:31: cannot find symbol
symbol : constructor SCJP_Richard_Raposa_Pg_189_Buffalo(boolean)
location: class java$program.SCJP_Richard_Raposa_Pg_189_Buffalo
SCJP_Richard_Raposa_Pg_189_Buffalo b=new SCJP_Richard_Raposa_Pg_189_Buffalo(false);
1 error
BUILD FAILED (total time: 0 seconds)


Actual Program:-




Please somebody help me to rectify my mistake and if possible please explain my mistake...
Thank You in advance.
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Pie
Posts: 15369
40
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch.

The error message says that the compiler cannot find a constructor for the class SCJP_Richard_Raposa_Pg_189_Buffalo that takes a boolean as an argument.

Looking at your source code, your class SCJP_Richard_Raposa_Pg_189_Buffalo indeed does not have such a constructor. So, you'll have to add it.
 
Matthew Brown
Bartender
Posts: 4567
8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That error message tells you that you're trying to use the constructor SCJP_Richard_Raposa_Pg_189_Buffalo(boolean) - on line 28 of the code above. But that class doesn't have a constructor that takes a boolean. Since you haven't defined a constructor the compiler will insert one, but it will insert one that takes no arguments.

So you either needs to change it to:or you need to add the missing constructor.
 
Campbell Ritchie
Sheriff
Pie
Posts: 49457
64
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And why are you using $ and _ symbols in your identifiers? That is not usually a recommended style.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic