Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

No suitable constructor found

 
Michael Giara
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


Is giving me

 
Steve Luke
Bartender
Posts: 4181
21
IntelliJ IDE Java Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The error message is pretty expressive and tells you exactly what the error is, and why the constructors won't work. So do you understand what the message is saying?
 
Michael Giara
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I fixed it by changing studentID from a string to an integer.

I was getting the error message because the constructor was identifying studentGrade as a string and not an integer, is that correct?
 
Michael Giara
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Correction:
I was getting the error because the file was saved in the wrong directory, one that did not contain my Student.java file.
I save to a different directory and the program displays a different error message.
I then copy and paste the program to the forum without comments.
I copy what I copied to the forum, back to jGRASP, and I get a different error message, which I correct, and the program compiles and executes.

Does that mean that by removing the comments, I removed something that was causing a compilation error?
 
Steve Luke
Bartender
Posts: 4181
21
IntelliJ IDE Java Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Michael Giara wrote:I was getting the error message because the constructor was identifying studentGrade as a string and not an integer, is that correct?

It was identifying the StudentID as a String (because it was a String, that is how you read it from the Scanner). It looks like you fixed the correct line, though.
 
Steve Luke
Bartender
Posts: 4181
21
IntelliJ IDE Java Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Michael Giara wrote:Correction:
I was getting the error because the file was saved in the wrong directory, one that did not contain my Student.java file.

I am not sure that is entirely true. The compiler was able to find Student and new what ctors it had, which means the Student class was available and findable.
Michael Giara wrote:I save to a different directory and the program displays a different error message.
I then copy and paste the program to the forum without comments.
I copy what I copied to the forum, back to jGRASP, and I get a different error message, which I correct, and the program compiles and executes.

Does that mean that by removing the comments, I removed something that was causing a compilation error?

Without knowing what the 'different error message' is or what you removed, it is impossible to say.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic