• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

problem with constructor and super

 
humanoidi ufo
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a class that extends another. There is something wrong with my constructor, but what?



It gives the following error message:
Suklaajaatelokone.java:19: kermanKulutus has private access in Jaatelokone
super.Jaatelokone(this.kermanKulutus, this.sokerinKulutus);
^
Suklaajaatelokone.java:19: sokerinKulutus has private access in Jaatelokone
super.Jaatelokone(this.kermanKulutus, this.sokerinKulutus);
 
John Dell'Oso
Ranch Hand
Posts: 130
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by humanoidi ufo:
I have a class that extends another. There is something wrong with my constructor, but what?



It gives the following error message:
Suklaajaatelokone.java:19: kermanKulutus has private access in Jaatelokone
super.Jaatelokone(this.kermanKulutus, this.sokerinKulutus);
^
Suklaajaatelokone.java:19: sokerinKulutus has private access in Jaatelokone
super.Jaatelokone(this.kermanKulutus, this.sokerinKulutus);


If you are explicitly calling the constructor of the parent class via super ,then the first line of the constructor of the subclass must call the constructor as super(parameters of the parent class constructor).

Regards,
JD
 
marc weber
Sheriff
Posts: 11343
Java Mac Safari
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"humanoidi ufo,"

Welcome to JavaRanch!

Please revise your display name to meet the JavaRanch Naming Policy. To maintain the friendly atmosphere here at the ranch, we like folks to use real (or at least real-looking) names.

You can edit your name here. Thank you for your prompt attention!

-Marc
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic