Results 1 to 3 of 3
  1. #1
    ravian is offline Senior Member
    Join Date
    Nov 2007
    Posts
    115
    Rep Power
    0

    Default Constructor calling

    I have the following strange issue. The constructor is not getting called. Does this mean that constructor can only be called if the object of this class is made in some other class.

    Java Code:
    public class Test {
    
    	public void Test()
    	{
    		System.out.println("Constructor called.");
    	}
    	public static void main(String[] args) {
    	Test obj = new Test();
    	}
    
    }

  2. #2
    Join Date
    Dec 2007
    Posts
    24
    Rep Power
    0

    Default

    y r u using void to the constructor

    Try without void then it works

  3. #3
    ravian is offline Senior Member
    Join Date
    Nov 2007
    Posts
    115
    Rep Power
    0

    Default

    Opps ... constructors don't have return type.
    Thanks mate.

Similar Threads

  1. Replies: 0
    Last Post: 12-19-2007, 10:10 AM
  2. Replies: 0
    Last Post: 12-19-2007, 10:01 AM
  3. Constructor Help
    By bluegreen7hi in forum New To Java
    Replies: 2
    Last Post: 11-15-2007, 06:44 AM
  4. Help with constructor in java
    By mathias in forum New To Java
    Replies: 1
    Last Post: 08-07-2007, 02:00 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •