I have below classes in the same package:
class Roo {
public String doRooThings()
{
return "Rooing!";
}
}
class Cloo extends Roo {
public static void main(String[] args)
{
System.out.println(doRooThings());
}
}
I get Cannot make a static reference to the non-static method doRooThings() from the type Roo error upon executing this.
But I can call the doRooThings() method (without having to preface it with a reference) from a public method in child class like below :
class Cloo extends Roo {
public void testRoo()
{
System.out.println(doRooThings());
}
public static void main(String[] args)
{
new Cloo().testRoo();
}
}
Can anyone please let me know how this works?