I have a Person class like this:
class persona {
private String dni;
private String nombre;
private String apel1;
private String apel2;
private String ciudad;
private String pais;
public persona(String dni, String nombre, String apel1, String apel2, String ciudad, String pais) {
this.dni = dni;
this.nombre = nombre;
this.apel1 = apel1;
this.apel2 = apel2;
this.ciudad = ciudad;
this.pais = pais;
}
/**
* @return the dni
*/
public String getDni() {
return dni;
}
/**
* @return the nombre
*/
public String getNombre() {
return nombre;
}
/**
* @return the apel1
*/
public String getApel1() {
return apel1;
}
/**
* @return the apel2
*/
public String getApel2() {
return apel2;
}
/**
* @return the ciudad
*/
public String getCiudad() {
return ciudad;
}
/**
* @return the pais
*/
public String getPais() {
return pais;
}
public void print(){
System.out.println("DNI: "+getDni());
System.out.println("Nombre: "+getNombre());
System.out.println("Apel1: "+getApel1());
System.out.println("Apel2: "+getApel2());
System.out.println("Ciudad: "+getCiudad());
System.out.println("Pais: "+getPais());
System.out.println("##########################3");
}
}
And in my test class I have a String with parameters separated by a comma. How can you divide that string and put it as attributes of my object?
public class Prueba {
public static void main(String[] args) {
persona p;
String s = "1234356B,ramon,retrasado,del culo,paris,francia;"
+ "4567823J,antonio,carrasco,garcia,madrid,españa";
}
}