Stupid java question: Is it a method?
Posted
by Stefan
on Stack Overflow
See other posts from Stack Overflow
or by Stefan
Published on 2010-03-17T18:17:59Z
Indexed on
2010/03/17
18:21 UTC
Read the original article
Hit count: 217
Hello,
I'm no Java guy, so I ask myself what this means:
public Button(Light light) {
this.light = light;
}
Is Button a method? I ask myself, because it takes an input parameter light. But if it was a method, why would it begin with a capital letter and has no return data type?
Here comes the full example:
public class Button {
private Light light;
public Button(Light light) {
this.light = light;
}
public void press() {
light.turnOn();
}
}
I know, this question is really trivial. However, I have nothing to do with Java and haven't found a description for the Button thing above. I'm just interested.
© Stack Overflow or respective owner