Good Morning. I have the following problem: When creating a class, with its attributes, methods, constructors, etc... It doesn't show me the constructors in the browser.
This is how it should look:
And this is how it appears to me:
My Point class has the following form:
public class Punto implements Serializable{
//Zona de atributos
private int x;
private int y;
//Constructores
public void Punto(int x, int y){ //Constructor con parametros
this.x = x;
this.y = y;
}
public void Punto (Punto p) { //Copia
this.x= p.x;
this.y= p.y;
}
public void Punto(){ //Constructor sin parametros
}
//Getters y Setters
public int getX() {
return x;
}
public void setX(int x) {
this.x = x;
}
public int getY() {
return y;
}
public void setY(int y) {
this.y = y;
}
//Mostrar y toString
public void mostrar(){
System.out.println("El punto corresponde a" + x + "," +y );
}
@Override
public String toString() {
return "El Punto es:\n" + "Cordenada x: " + x + "\nCoordenada y: " + y + "\n";
}
}
The constructor does not carry the modifier
void
. In fact, he doesn't have any modifiers. That is precisely the difference with a non-constructor method. By usingvoid
, you are making a set, that is, updating the values of an already created object .