I'm trying to break the following ArrayList
with a String
:
ArrayList<Funcionario> funcionarios = new ArrayList();
But when I instantiate the object, I add the values in there through my method and I try to use split
, the compiler underlines the .split
in red and gives error. I am trying to separate the information by a space " "
.
Funcionario func = new Funcionario(); //Instancio o obj
func.cadastrar(); //CHama o método que lê o teclado
funcionarios.add(func); // Manda pro ArrayList
System.out.println("\n\n\nFuncionario cadastrado: \n" + func.toString()); //Mostra o que foi adicionado
System.in.read();
func.gravar(); //Salva em um txt
String[] separado = funcionarios.split(" "); //Aqui dá erro
Does anyone know what the error is?
I want to separate the registered information for each employee (name, e-mail, telephone, salary) in% with% s separated.
I want to break in String
s to be able to add in a vector, sort and then be able to create a String
sorted by name (in one of the application options) or salary (another part of the code).
Thank you
public String toString()
{
return "\nNome: " + nome
+ "\nEmail: " + email
+ "\nTelefone: " + telefone
+ "\nSalario: R$ " + salario ;
}