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
  1. In the Projects view, right-click (Mac OS: 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. 

  1. 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.
  2. Click Next to go to the next page of the wizard. 

  1. 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.
  2. Using Create constructor and Create toString() method check boxes, specify whether you want default class constructor and toString() method to be created automatically.  
  3. Click Finish to complete the process. You will see the code editor for the created class opened.