Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Constructors Compile Error

 
Omar Jouda
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why Can't I create this constructor? What is going wrong?


 
Roel De Nijs
Sheriff
Posts: 10225
129
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Because your constructor has invalid syntax. Take a close look to your constructor and see if you can spot the problem.
 
Omar Jouda
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Roel De Nijs wrote:Because your constructor has invalid syntax. Take a close look to your constructor and see if you can spot the problem.

The parenthesis for empty parameters?
So it should be public Earth() { etc.. } .

I wrote it exactly as in a book of mine. Apparently it is wrong.

Thanks!
 
Roel De Nijs
Sheriff
Posts: 10225
129
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Omar Jouda wrote:The parenthesis for empty parameters?
So it should be public Earth() { etc.. } .

Exactly!

Omar Jouda wrote:I wrote it exactly as in a book of mine. Apparently it is wrong.

You always have to be careful when copying from a book. Authors do a very good job trying to make the book free of mistakes, but it's very, very dificult process and unfortunately sometimes a mistake is not seen by the author and/or the technical review team. That's why most of the books have an errata section (in the book and/or online).
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic