This week's book giveaway is in the General Computing forum.
We're giving away four copies of Arduino in Action and have Martin Evans, Joshua Noble, and Jordan Hochenbaum on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes method declaration Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Java » Beginning Java
Reply Bookmark "method declaration" Watch "method declaration" New topic
Author

method declaration

ian myers
Greenhorn

Joined: Apr 11, 2011
Posts: 7



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

Joined: May 29, 2005
Posts: 479
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

Joined: Oct 25, 2008
Posts: 2700

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.


"Any fool can write code that a computer can understand. Good programmers write code that humans can understand." --- Martin Fowler
Please correct my English.
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: method declaration
 
Similar Threads
How to set FoucsTraversalPolicy in GridLayout
Copying Components
Expanding JPanel
Swing components not shown
Unable to set label icon