fork download
  1. class Perro{
  2. //Los perros tienen atributos:
  3. String nombre, raza;
  4. int edad;
  5.  
  6. //Y tienen comportamiento:
  7. public void ladra(){
  8. System.out.println("Wow wow!");
  9. }
  10.  
  11. //Siempre que se creen los perros, necesitamos asignarle su nombre y su edad
  12. Perro(String nombre, int edad){
  13. this.nombre=nombre;
  14. this.edad=edad;
  15. }
  16.  
  17. public static void main(String args[]){
  18. Perro firulais = new Perro("firulais",23);
  19. firulais.ladra();
  20. }
  21. }
Success #stdin #stdout 0.1s 320256KB
stdin
Standard input is empty
stdout
Wow wow!