wood burning stoves 2.0*
The moose likes Beginning Java and the fly likes constructor Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "constructor" Watch "constructor" New topic
Author

constructor

sandeep Talari
Ranch Hand

Joined: Dec 24, 2007
Posts: 63
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

Joined: Mar 22, 2008
Posts: 265

This fails for the same reasons that are discussed in this thread.


There will always be people who are ahead of the curve, and people who are behind the curve. But knowledge moves the curve. --Bill James
amitabh mehra
Ranch Hand

Joined: Dec 05, 2006
Posts: 98
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.
 
jQuery in Action, 2nd edition
 
subject: constructor