• Post Reply Bookmark Topic Watch Topic
  • New Topic

Question regarding constructors  RSS feed

 
Arjun Reddy
Ranch Hand
Posts: 629
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

I did not understand the following statement when I was reading about constructors in the SCJP book by Kathy Sierra and Bert Bates.

You can access static variables and methods, although you can use
them only as part of the call to super() or this(). (Example:
super(Animal.DoThings()))


Can someone please tell me what it means?

Thanks.
 
Campbell Ritchie
Marshal
Posts: 56600
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please provide more details. Is that in a Constructor? It would appear that you are calling a static Animal.doThings() method and passing its return value to the superclass constructor.

Maybe not a good idea for production use; you ought to avoid calling methods from a constructor unless they are final or have private access.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!