Difference between ActionListener as class vs as object

Hello, I was wondering what the difference was in setting a class to implement ActionListener and utilizing that class as the listener itself vs creating a private ActionListener actionListener inside the class and having it deal with input. Additional curiosity: in the “Hello Collision” tutorial they map the listeners this way:

inputManager.addListener(this, "Left");
inputManager.addListener(this, "Right");
inputManager.addListener(this, "Up");
inputManager.addListener(this, "Down");
inputManager.addListener(this, "Jump");

Whereas I did it this way:

    inputManager.addListener(this, "Forward", "Backward", "Left", "Right", "Jump");

Is there a real difference between these two?

Thank you! :slight_smile:

The first one exposes a public method to any weird code that might call it. It’s generally a bad practice though in your own code you can get away with it. Especially if you are a team of one.

There is no down side to the other approach, though.

Nope. One is easier to cut and paste new lines into I guess. (shrug)

Ty very much! :slight_smile: