+ 1
help ( java ) I m a beginner. Please decode.
3 Respuestas
+ 1
@mike thank you very much
0
Well there are a couple of things wrong with your code. If you want classes and subclasses you need to make the cat class extend the animal class for starters. You also forgot to make the values and the
propert function public.
// Created by kxlee
public class Animals{
public String name;
public int age;
public int legs;
static class Cats extends Animals {
int legs = 4;
public void propert() {
System.out.print("Miow, my name is " + this.name);
System.out.println("my age is " + this.age + " , I have " + legs + " legs." );
}
}
}
class MyClass{
public static void main(String []args){
Animals.Cats jex=new Animals.Cats();
jex.name="Jex";
jex.age=14;
jex.propert();
}
}
0
You just posted the same code from before but here is my working version of it.
https://code.sololearn.com/cql5KqOF9f5a/?ref=app