There is an interface:

public interface RobotConnectionManager { RobotConnection getConnection(); } 

And there is a method:

 public static void moveRobot(RobotConnectionManager robotConnectionManager, int toX, int toY) { RobotConnection rc = robotConnectionManager.getConnection(); rc.moveRobotTo(toX, toY); } 

I do not understand, but according to this there are a trace. questions:

  1. when the moveRobot(); method is called in Main moveRobot(); don't understand what should i write to robotConnectionManager ?

  2. RobotConnection is also an interface with its own method. How in Java to explain what is happening in this line: RobotConnection rc = robotConnectionManager.getConnection(); What you need to read to understand it.

1 answer 1

  1. You must first pass a class instance (object) that implements the RobotConnectionManager interface.

  2. The getConnection method is called on an object stored in the variable robotConnectionManager . This method returns an instance (object) of a class that implements the RobotConnection interface.

You should read any Java tutorial and / or official tutorial .