El error que presenta es:
Exception in thread "main" java.util.NoSuchElementException: No line found at java.util.Scanner.nextLine(Unknown Source).
Tengo un metodo readAddress que obtiene los valores de la clase. Este metodo es llamado desde otra clase Employee
para leer la Address
del Employee
entre otros atributos. Adjunto los dos metodos. Cuando testeo los metodos por separado funciona bien.
public void readAddress() {
Scanner read = new Scanner(System.in);
String string;
System.out.println("Address(Separate each data with '/'): ");
string = read.nextLine();
String[] substring = string.split("/");
this.building = substring[0];
this.apartment = substring[1];
this.street = substring[2];
this.city = substring[3];
this.province = substring[4];
this.code = substring[5];
read.close();
}
public void readEmployee() {
Scanner read = new Scanner(System.in);
System.out.println("Last name: ");
this.lastname = read.nextLine();
System.out.println("First name: ");
this.firstname = read.nextLine();
this.email.readEmail();
this.address.readAddress();
this.telephone.readTelephone();
System.out.println("Social security number: ");
this.ssn = read.nextLine();
read.close();
}
El error esta sobre la linea:
string = read.nextLine();