Adding Java Classes
AnyLogic allows the user to create his/her own Java classes in the model with any required functionality.
To add a Java class
- In the
view, right-click (Mac OS: Ctrl click) the model item you are currently working with, and choose
New > Java Class…
from the popup menu.
New Java Class
wizard is displayed.
- On the first page of the wizard, specify the name of the new Java class in the
field and optionally type in the superclass name in the
to go to the next page of the wizard.
- On the second page of the wizard, specify Java class fields. Fields are specified in the table, each class field is defined in the separate row. Enter the type of the field in the
cell, name of the field in the
cell and optionally name the access modifier in the
cell and specify the initial value in the
Create toString() method
check boxes, specify whether you want default class constructor and toString() method to be created automatically.
to complete the process. You will see the code editor for the created class opened.