Kind of a noob question, this, but I can't figure it out.
This is an animal. Java. I want him to be a superclass for all animal subclasses. It is in the same package as all subclasses.
public class Animal { protected static String call = "Animals make noises, but do not have a default noise, so we're just printing this instead."; public static void sound() { System.out.println(call); } }
This is cow.java
class Cow extends Animal { call = "moo"; }
Obviously this does not work. But I want to be able to run Cow.sound () and output the output of "moo". I also want to be able to create more classes that override the "call" with their own string. What should I do instead?
source share