public class Persona {
private String nombre, DNI;
private char sexo;
private int edad, altura;
private float peso;
Persona(){
nombre = "";
sexo = 'M';
edad = 0;
altura = 0;
peso = 0;
}
String generaDNI(){
String DNI = "";
int x = (int)(Math.random() * 100000000 + 1);
DNI += Integer.toString(x);
return DNI;
}
}
So this is my code. What I want to do is, whenever I call the constructor, i want the attribute "DNI" to call the method "generaDNI", so the value of "DNI" is given by the method. How can I do it?