Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

method declaration

 
ian myers
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator



whenever i try to compile i get this

Labels.java:12: invalid method declaration; return type required
public Label()
^



i realize it wants a return type but its a constructor
 
Ralph Cook
Ranch Hand
Posts: 479
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If it's a constructor, it needs to be in the class named "Label". THIS class is named "Labels".

Or you could put the 's' on this one.

rc
 
Wouter Oet
Saloon Keeper
Posts: 2700
IntelliJ IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A small remark: I would move all your instance variables to the constructors since you don't use them in other methods. When you do need them from other methods then just move them one by one back.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic