This week's book giveaway is in the Agile and other Processes forum.
We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund 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
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Beginning Java
Reply 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.
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: constructor
 
Similar Threads
Math.abs()
Problem while playing with Reflection
regarding Serializable
Problem with constructors
Whizlabs quiestion, support and new SCJA Policy