AnyLogic
Expand
Font size

Adding Java classes

AnyLogic allows the user to create their own Java classes in the model with any required functionality.

To add a Java class

  1. In the Projects view, right-click (macOS: Ctrl + click) the model item you are currently working with, and choose New > Java Class… from the popup menu.
  2. The New Java Class wizard is displayed.

  3. On the first page of the wizard, specify the name of the new Java class in the Name field and optionally type in the superclass name in the Superclass edit box.
  4. Click Next to go to the next page of the wizard.

  5. 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 Type cell, name of the field in the Name cell and optionally name the access modifier in the Access cell and specify the initial value in the Initial value cell.
  6. Using Create constructor and Create toString() method check boxes, specify whether you want default class constructor and toString() method to be created automatically.
  7. Click Finish to complete the process. You will see the code editor for the created class opened.

How can we improve this article?