Win a copy of OCP Java SE 8 Programmer II Exam Study Guide this week in the OCP forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Problem Working An Example calling Super()  RSS feed

 
Ranch Hand
Posts: 81
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, all:

I am killing some time reviewing simple java examples and expanding on thems. I am have trouble with the follow example:



I don't understand how to properly call the BaseBall method.

Source:
Page 287, 288 Java All-in-one desk reference for Dummies, 2nd Edition

Thanks.

Preston@Large
 
Sheriff
Posts: 21288
87
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What method? Your classes don't have any methods. They have constructors, and you already call that one on line 34 (new BaseBall()). After that the object is constructed and you can't call the constructor on it anymore.
 
Ranch Hand
Posts: 160
Java Netbeans IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
here there are no methods named BaseBall. You are trying to call a constructor which is not possible....
 
Preston Thornton
Ranch Hand
Posts: 81
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yep! You're right! Thanks.
 
Marshal
Posts: 58388
178
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
. . . and it would be a bad idea to write a method that looks so similar to a constructor.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!