Wednesday, May 23, 2012

Extended class running from super via same method (Java)

The title is pretty confusing I know but I could not think of another way of wording it.



So, what I am trying to achieve: I have seen some java programs have a load of subclasses that have a method in their super class, and they all run when the supers method is called.



I have tried multiple things and I've googled a lot but what I've found doesn't work for me.



Here is what I have: The SUPER class



public class Synchroniser 
{
public Synchroniser()
{
RunAll();
}

protected void RunAll()
{
System.out.println("RunAll");
}
}


The SUBCLASS:



import org.lwjgl.input.Keyboard;

public class ArrayList extends Synchroniser
{
public ArrayList()
{

}

public static void Keybind(Info info)
{
info.Toggle();
}

@Override
protected void RunAll()
{
System.out.println("Ran ArrayList");
}
}




No comments:

Post a Comment