RETORNO DE VALORES
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=null;
if(r1!=null)
r1.isQuadrado();
//NullPointerException
}
}
Tags java, orientado, a, objetos
Comentários
comments powered by Disqus