Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

constructor

 
sandeep Talari
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
F:\javaprogs>javac B.java
B.java:12: cannot find symbol
symbol : constructor A()
location: class A
{
^
1 error

class A
{
A(int i , int y)
{
System.out.println("im in class A");
}
}

class B extends A
{
B(int x, int z)
{
System.out.println("im in class B");
}
public static void main(String [] args)
{
B b = new B(12,12);
}
}

[ May 27, 2008: Message edited by: sandeep Talari ]
[ May 27, 2008: Message edited by: sandeep Talari ]
 
Stevi Deter
Ranch Hand
Posts: 265
Hibernate Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This fails for the same reasons that are discussed in this thread.
 
amitabh mehra
Ranch Hand
Posts: 98
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If super doesn't appear as the first statement of a constructor body, the Java compiler inserts an implicit call -- super() -- to the immediate superclass constructor.

So either you provider a default constructor in your super class or call super(x, z) as first statement in your subclass constructor.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic