This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes No suitable constructor found Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "No suitable constructor found " Watch "No suitable constructor found " New topic
Author

No suitable constructor found

Michael Giara
Greenhorn

Joined: Apr 11, 2013
Posts: 10


Is giving me

Steve Luke
Bartender

Joined: Jan 28, 2003
Posts: 4167
    
  21

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?

Steve
Michael Giara
Greenhorn

Joined: Apr 11, 2013
Posts: 10
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

Joined: Apr 11, 2013
Posts: 10
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

Joined: Jan 28, 2003
Posts: 4167
    
  21

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

Joined: Jan 28, 2003
Posts: 4167
    
  21

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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: No suitable constructor found
 
Similar Threads
How to compare the new student with ArrayList.
new elements in the arraylist
getting java.lang.NoSuchMethodError: main error! thanks =)
Inheritance
Set vs List