This week's book giveaway is in the Kotlin forum.
We're giving away four copies of Kotlin in Action and have Dmitry Jemerov & Svetlana Isakova on-line!
See this thread for details.
Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Simple subclass problem  RSS feed

 
Nitin Bhagwat
Ranch Hand
Posts: 132
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please help me to understand this simple error. Constructor of class A must have a parameter int i.
* Program gives compile time error : on line 16 and 25

class tst
{
public static void main(String st[])
{
B b = new B();
}
}

class A
{
A (int i)
{
System.out.println("A Constructor");
}

B extends A
{
int i = 2
B()
{
super(i);
System.out.println("B Constructor");
}
}
}
 
Dirk Schreckmann
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Do you notice anything missing from the following line of code?

int i = 2

Remember, all Java statements end in a... what?
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!