INSTÂNCIA
c:: |
EXEMPLO FEITO EM AULA
class Retangulo{
public int width, height;
public int areaTotal(){
return width * height;
}
public boolean isQuadrado(){
if(width==height)
return true;
return false;
}
}
public class Main {
public static void main(String args[]){
Retangulo r1 = new Retangulo();
Retangulo r2;
r2 = r1;
r1.width = 1000;
int i1 = 10;
int i2 = i1;
i2 = 20;
//System.out.println(r1.width);
//System.out.println(r2.width);
System.out.println(i1);
System.out.println(i2);
}
}
Tags java, orientado, a, objetos
Comentários
comments powered by Disqus