Method. That’s it. Specifically it’s an instance method, but normally we don’t need to specify it completely.
The constructor is only the one that has the same class name and has no return, and that in theory should build something, ie assign values to the class attributes or do something at startup. So there are no constructors in your class, at least not explicitly. There is even a default implicit constructor.
class Main {
public static void main(String[] args) {
Teste1 teste = new Teste1(); //criando a classe com um construtor implícito
System.out.println("Criou a classe");
teste.Teste1(); //está chamando o método normal declarado
}
}
class Teste1 {
public void Teste1() { //este método não é um construtor
System.out.println("Olá");
}
public void Teste2() {
System.out.println("Oi");
}
}
Behold working in the ideone. And in the repl it.. Also put on the Github for future reference.
It’s just a common method, no big deal. And
Teste1
He is not a builder, because builders have no return. The only thing that’s different is that you’re not following the method names rule of being Camelcase, and start with minuscule letter.– user28595
So I’m getting it all wrong even the
– Kelvin Crepaldi
Did the answer solve your question? Do you think you can accept it? See [tour] if you don’t know how you do it. This would help a lot to indicate that the solution was useful for you. You can also vote on any question or answer you find useful on the entire site (when you have 15 points).
– Maniero