Results 1 to 4 of 4
  1. #1
    McChill is offline Member
    Join Date
    Feb 2009
    Posts
    47
    Rep Power
    0

    Default [SOLVED] Constructor problem

    I'm just trying to create this constructor and it is telling me "Return type for the method is missing." I was under the impression that constructors do not need a return type and am pretty angered that it will not compile. This is the code for the class. I can include the rest of the app if it is necessary.
    Java Code:
    package tents;
    public class TentC extends Tent implements Waterproof{
    	
    	public TypeC()
    	{
    		type = "C";
    	}
    
    	public String getType()
    	{
    		return type;
    	}
    	
    	
    }

  2. #2
    McChill is offline Member
    Join Date
    Feb 2009
    Posts
    47
    Rep Power
    0

    Default

    Actually, in this class I just want to display if it is waterproof.
    Java Code:
    package tents;
    
    public class Display {
    	Tent[] tents = new Tent[3];
    	TentA tentA = new TentA();
    	tent[0] = tentA;
    	TentB tentB = new TentB();
    	tent[1] = tentB;
    	TentC tentC = new TentC();
    	tent[2] = tentC;
    	
    	for(int x = 0; x< tents.length ; x++)
    	{
    		if(tents[x] instanceof Waterproof)
    			System.out.println("This tent is waterproof. It if of " + tents[x].getType());
    	}
    	
    	
    
    	}
    }
    Java Code:
    	TentA tentA = new TentA();
    is telling me "syntax error on token ;, { expected after this token"

    I'm confused...I don't see a syntax error. But then again I am a pretty big noob here.

  3. #3
    McChill is offline Member
    Join Date
    Feb 2009
    Posts
    47
    Rep Power
    0

    Default

    so nevermind on that second one...no main method.

  4. #4
    McChill is offline Member
    Join Date
    Feb 2009
    Posts
    47
    Rep Power
    0

Similar Threads

  1. Problem with Constructor
    By ToastyBainey in forum New To Java
    Replies: 3
    Last Post: 03-09-2009, 03:36 AM
  2. [SOLVED] Constructor problem
    By sfe23 in forum New To Java
    Replies: 10
    Last Post: 02-21-2009, 09:22 PM
  3. Replies: 0
    Last Post: 12-19-2007, 10:10 AM
  4. Replies: 0
    Last Post: 12-19-2007, 10:01 AM
  5. Constructor Help
    By bluegreen7hi in forum New To Java
    Replies: 2
    Last Post: 11-15-2007, 06:44 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
  •