2
I created a Class Cliente
with attributes name, age, address,Cpf. And in the main class I went to do a ArrayList
of the kind Cliente
, thus ArrayList Cliente<String> = new ArrayList<>();
in order to create an array that will grow in size while I am registering Customers.
However, how do I put the information in the attributes of Cliente
of a particular Journal of the ArrayList
?
For example, if I have Intel zero, I wanted to do something like Cliente.nome.add("Joao");
And so I was assigning the values in the same way to the age, address, Cpf attributes.
Is there any way I can do that? Because in the tutorials of how to make a registration that I saw only put type Cliente.add("Joao");
and I didn’t want to put only name, since I have several attributes to register.
The class I created was like this :
public abstract class Pessoa {
private String nome,sexo,cpf,endereco,email,dataNascimento;
private int telefone;
public String getSexo() {
return sexo;
}
public void setSexo(String sexo) {
this.sexo = sexo;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public String getDataNascimento() {
return dataNascimento;
}
public void setDataNascimento(String dataNascimento) {
this.dataNascimento = dataNascimento;
}
public int getTelefone() {
return telefone;
}
public void setTelefone(int telefone) {
this.telefone = telefone;
}
public String getNome() {
return nome;
}
public void setNome(String nome) {
this.nome = nome;
}
public String getCpf() {
return cpf;
}
public void setCpf(String cpf) {
this.cpf = cpf;
}
public String getEndereco() {
return endereco;
}
public void setEndereco(String endereco) {
this.endereco = endereco;
}
}
And in the Main Class I wanted to access my Attributes only using Arrylist type
public static void main(String[] args) {
ArrayList<String> Cliente = new ArrayList<>();
Cliente.nome.add("Joao");
Obs : Esta linha acima que fiz está errada porque eu nao sei como acessar esses atributos.
}
By the way, it’s not really a question about the graphical api, but even so you could add one [mcve] because it helps to better understand the problem.
– user28595
So, bro. It didn’t even have to be in Swing no, I just wanted to know how I accessed the attributes of a particular Dice from an Arraylist. The class I created was just the basic one I quoted up there, but I don’t know how to access the attributes of an Arraylist.
– Genielson