Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

SuperClasses

 
ryan vines
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I am having trouble calling a superclass constructer. I am trying to call this code but when trying to call it using this code it give me an error saying
I dont know what to do. Please help asap.
Ryan Vines
 
Andres Gonzalez
Ranch Hand
Posts: 1561
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
protected double balance
this is not a constructor ryan, it's a method. Constructors do *not* have a return type.
 
ryan vines
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Oops, sry.. That is supposd to be
Sry
 
Andres Gonzalez
Ranch Hand
Posts: 1561
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by ryan vines:
Oops, sry.. That is supposd to be
Sry

Still don't understant. This code is *not* a constructor.

This is a constructor, it doesn't have a return type.
 
Nathaniel Stoddard
Ranch Hand
Posts: 1258
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm not sure where your double balance is, BUT
Private instance variables aren't valid and accessible until after all parent-classes' constructors have finished.
So, if you're trying to pass that (undefined) balance to the base class' constructor, that may be what it is whining about. Although, it's all speculation because your code came in pieces in the post.
But maybe that will help you find out what is happening.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic