4
I have a college job that I need to create several instances of an object Pessoa
and save these instances in a listing to show the user when needed (this will work as a database). Since we haven’t seen the database yet, I can’t put this in it, so I’m looking for another option. Searching I saw that it seems possible to do using Interfaces.
Here is my class Pessoa
:
public class Pessoa {
private int id;
private String nome;
private char sexo;
private String telefone;
Pessoa(int id, String, nome, char sexo, String telefone){
this.id = id;
this.nome = nome;
this.sexo = sexo;
this.telefone = telefone;
}
public int getId(){ return this.id; }
public void setId(int id){ this.id = id; }
public String getNome(){ return this.nome; }
public void setNome(String nome){ this.nome = nome; }
public char getSexo(){ return this.sexo; }
public void setSexo(char sexo){ this.sexo = sexo; }
public char getTelefone(){ return this.telefone; }
public void setTelefone(String telefone){ this.telefone = telefone;}
}
I need it on my app every time I call one new Pessoa()
i have how to save this object somewhere in the code without using TXT files, databases or similar. Is there any method of doing this in Java, something like a cache?
Arraylist does not solve?
– user28595
Research on EJB and JNDI
– M8n