Adding Java Interfaces
AnyLogic allows the user to add Java interfaces to a model.
Please refer to
section of Java online tutorials for more information on Java interfaces.
To add a Java interface
- In the
view, right-click (Mac OS: Ctrl click) the model item you are currently working with, and choose
New > Java Interface…
from the popup menu.
New Java Interface
dialog box is displayed.
- Specify the name of the new Java interface in the
field and click
to complete the process.
- You will see Java editor opened prompting you to write Java code for the just defined interface.
To use an interface, you write a class that implements the interface. When an instantiable class implements an interface, it provides a method body for each of the methods declared in the interface.
To make agent class implementing an interface
- Select the agent type in the
- In the
section of the
view, type the interface name in the
Implements (comma-separated list of interfaces)
To make Java class implementing an interface
- Double-click the Java class in the
view to open its code in the Java editor.
- Complete the first code line containing the class name with the string