I'm having a college assignment that I need to create multiple instances of a Pessoa
object and save those instances to a listing to show the user when needed (this will work as a database). As we have not seen database I still can not insert this into it so I am looking for another option. Searching, I saw that this seems to be 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 in my application every time I call a new Pessoa()
I have how to save that object somewhere in the code without using TXT files, databases or similar. Is there any method to do this in Java, something like a cache?