This week's book giveaway is in the Game Development forum.
We're giving away four copies of Badass: Making Users Awesome and have Kathy Sierra on-line!
See this thread for details.
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

Win a copy of Badass: Making Users Awesome this week in the Game Development forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "constructor" Watch "constructor" New topic


sandeep Talari
Ranch Hand

Joined: Dec 24, 2007
Posts: 63
F:\javaprogs>javac 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.
I agree. Here's the link:
subject: constructor