permaculture playing cards*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes constructor Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "constructor" Watch "constructor" New topic
Author

constructor

radhika ayirala
Greenhorn

Joined: Aug 28, 2007
Posts: 24
public class test
{
public static void main( String [] args )
{
new test();
}
test()
{
test(2);
}
test(int x)
{
System.out.println(x);
}
}


why is this giving an error?
Chang Tzu-yu
Greenhorn

Joined: Sep 17, 2007
Posts: 16
Call Constructor must use "this(2)"
public class test {
public static void main(String[] args) {
new test();
}

test() {
this(2);
}

test(int x) {
System.out.println(x);
}
}


Chang Tzu-yu<br /> <br />SCJP 1.4
radhika ayirala
Greenhorn

Joined: Aug 28, 2007
Posts: 24
thanks
chandraiah chintakayalu
Ranch Hand

Joined: Aug 30, 2007
Posts: 32
when your calling a super constructor it should be called as:
super(2);


SCJP-5 86%,SCWCD-soon
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: constructor
 
Similar Threads
Calling a method
static block understanding
Bitwise inversion operator question
Is this java's Bug
can't call another constructor from no-arg constructor