u02
This commit is contained in:
parent
dbaec404d7
commit
5dc20bf05e
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
|
@ -0,0 +1,23 @@
|
|||
class Cliente {
|
||||
private int codigo;
|
||||
private String nome;
|
||||
public Cliente (){
|
||||
this.codigo = 0; this.nome = "";
|
||||
}
|
||||
public Cliente (int codigo, String nome){
|
||||
this.codigo = codigo; this.nome = nome;
|
||||
}
|
||||
public int getCodigo(){ return codigo; }
|
||||
public void setCodigo(int codigo){ this.codigo = codigo; }
|
||||
public String getNome(){ return nome; }
|
||||
public void setNome(String nome){ this.nome = nome; }
|
||||
|
||||
public Cliente clone (){
|
||||
Cliente resp = new Cliente();
|
||||
resp.codigo = this.codigo;
|
||||
resp.nome = this.nome;
|
||||
return resp;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -5,10 +5,10 @@
|
|||
*/
|
||||
class Ponteiro01Array {
|
||||
public static void main (String[] args) {
|
||||
int[] vet = new int [10];
|
||||
int[] vet = new int [5];
|
||||
System.out.println(vet);
|
||||
|
||||
vet = new int [10];
|
||||
vet = new int [5];
|
||||
System.out.println(vet);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,14 @@
|
|||
class Ponteiro08Objeto {
|
||||
public static void main(String args[]){
|
||||
Cliente c1 = new Cliente(1, "aa");
|
||||
Cliente vet[] = new Cliente [5];
|
||||
|
||||
System.out.println("c1 -->> [" + c1 + "] -- [" + c1.getCodigo() + "/" + c1.getNome() + "]");
|
||||
|
||||
for(int i = 0; i < vet.length; i++){
|
||||
vet[i] = c1.clone();
|
||||
System.out.println("vet["+ i +"] -->> [" + vet[i] + "] -- [" + vet[i].getCodigo() + "/" + vet[i].getNome() + "]");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue