I think the error is because it is badly invoked, either by the part that needs a constructor, or that you do not have methods to enter the data properly.
I guess the "Date" class looks like this:
public class Fecha {
private int dia, mes, anio;
public void setDia(int dia) {
this.dia = dia;
}
public void setMes(int mes) {
this.mes = mes;
}
public void setAnio(int anio) {
this.anio = anio;
}
}
If so, you would have to add the values as follows:
public class main {
public static void main(String[] args) {
Fecha f1 = new Fecha();
f1.setAnio(2018);
f1.setMes(10);
f1.setDia(04);
Fecha f2 = new Fecha();
f2.setAnio(2018);
f2.setMes(10);
f2.setDia(04);
if (f1.equals(f2)) {
System.out.println("Son iguales");
} else {
System.out.println("Son distintas...");
}
}
}
Another way is adding a constructor to the "Date" class:
public class Fecha {
private int dia, mes, anio;
public Fecha(int dia, int mes, int anio) {
this.dia = dia;
this.mes = mes;
this.anio = anio;
}
}
And when invoked, they are entered in the following way:
public class main {
public static void main(String[] args) {
Fecha f3 = new Fecha(04, 10, 2018);
Fecha f4 = new Fecha(04, 10, 2018);
if (f3.equals(f4)) {
System.out.println("Son iguales");
} else {
System.out.println("Son distintas...");
}
}
}
Greetings