What is this type of method?

I’m on my way to work on the gamepad support. But I found this interface method on the JoyInput class (see below). What does it do? How does it work?

Firstable, the InputManager class creates an instance of Joyinput instead of implementing it. I didn’t know you could do that with an interface.

Secondable, the loadJoysticks method returns something of the type JoyStick but the method doesn’t have a return statement. What’s happening here? Also, the returned JoyStick value is supposed to be an array but the InputManager’s call of this method doesn’t ask for a Joystick[] array.

[java]
package com.jme3.input;

…JoyInput…
{

/**
* Loads a list of joysticks from the system.
*
* @param inputManager The input manager requesting to load joysticks
* @return A list of joysticks that are installed.
*/
public Joystick[] loadJoysticks(InputManager inputManager);
}
[/java]

This is the other code (see below) that calls the method above .

[java]

package com.jme3.input;

…InputManager…
{

public InputManager(MouseInput mouse, KeyInput keys, JoyInput joystick, TouchInput touch) {

       JoyInput   joysticks = joystick.loadJoysticks(this); // JoyInput word was added for illustration purposes, it doesn't appear on the real code

}
[/java]

summon: @iwgeric

@Pixelapp said: I'm on my way to work on the gamepad support. But I found this interface method on the JoyInput class (see below). What does it do? How does it work?

It calls the underlying joystick support to figure out what is connected and creates Joystick objects that return the info about them.
http://code.google.com/p/jmonkeyengine/source/browse/trunk/engine/src/lwjgl/com/jme3/input/lwjgl/JInputJoyInput.java

@Pixelapp said: Firstable, the InputManager class creates an instance of Joyinput instead of implementing it. I didn't know you could do that with an interface.

I don’t know what you are talking about here. The JoyInput instance was provided to InputManager during construction:
InputManager(MouseInput mouse, KeyInput keys, JoyInput joystick, TouchInput touch)
http://code.google.com/p/jmonkeyengine/source/browse/trunk/engine/src/core/com/jme3/input/InputManager.java#132

@Pixelapp said: Secondable, the loadJoysticks method returns something of the type JoyStick but the method doesn't have a return statement. What's happening here? Also, the returned JoyStick value is supposed to be an array but the InputManager's call of this method doesn't ask for a Joystick[] array.

…and now you’ve totally lost me. What code are you looking at?

Ok, I had a hunch this was the answer, but now it’s confirmed.