Results 1 to 4 of 4
Thread: [SOLVED] Constructor problem
- 03-09-2009, 06:29 PM #1
Member
- Join Date
- Feb 2009
- Posts
- 47
- Rep Power
- 0
[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; } }
- 03-09-2009, 06:32 PM #2
Member
- Join Date
- Feb 2009
- Posts
- 47
- Rep Power
- 0
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()); } } }is telling me "syntax error on token ;, { expected after this token"Java Code:TentA tentA = new TentA();
I'm confused...I don't see a syntax error. But then again I am a pretty big noob here.
- 03-09-2009, 06:37 PM #3
Member
- Join Date
- Feb 2009
- Posts
- 47
- Rep Power
- 0
so nevermind on that second one...no main method.
- 03-09-2009, 06:43 PM #4
Member
- Join Date
- Feb 2009
- Posts
- 47
- Rep Power
- 0
Similar Threads
-
Problem with Constructor
By ToastyBainey in forum New To JavaReplies: 3Last Post: 03-09-2009, 02:36 AM -
[SOLVED] Constructor problem
By sfe23 in forum New To JavaReplies: 10Last Post: 02-21-2009, 08:22 PM -
Calling constructor of parent class from a constructor
By Java Tip in forum Java TipReplies: 0Last Post: 12-19-2007, 09:10 AM -
Calling constructor of same class from a constructor
By Java Tip in forum Java TipReplies: 0Last Post: 12-19-2007, 09:01 AM -
Constructor Help
By bluegreen7hi in forum New To JavaReplies: 2Last Post: 11-15-2007, 05:44 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks