Class Construction Problem.

Hi All,

publicclass Class1

{

Class2 test;

publicvoid call_class2()

{

test =new Class2();// prints " From contructor "

test.init();// prints " From init "

}

publicstaticvoid main(String[] args)

{

Class1 c1 =new Class1();

c1.call_class2();

}

}

class Class2

{

publicvoid Class2()

{

System.out.println(" From contructor ");

}

publicvoid init()

{

System.out.println(" From init ");

}

}

Regarding above code, I want to print " From contructor " and "From init". But It prints only "From init". My mistake is ?

Thanks...

[1591 byte] By [Terry_ba] at [2007-11-27 9:17:18]
# 1
public void Class2() // not a constructor, just a very poorly named methodpublic Class2() // constructor
jverda at 2007-7-12 22:07:37 > top of Java-index,Java Essentials,Java Programming...
# 2
Thanks for showing my mistake...
Terry_ba at 2007-7-12 22:07:37 > top of Java-index,Java Essentials,Java Programming...
# 3
> Thanks for showing my mistake...whatever you do, don't be embarrassed by that one. I know that many of us tripped up on that starting out.
petes1234a at 2007-7-12 22:07:37 > top of Java-index,Java Essentials,Java Programming...
# 4
I've come to appreciate the VB.NET solution: naming constructors "Sub New" instead of naming them after the class.
BigDaddyLoveHandlesa at 2007-7-12 22:07:37 > top of Java-index,Java Essentials,Java Programming...