title: JavaFX - Auto increment ID
body: <p>This is what I have</p>
  <pre><code>public class AddNewCategoryController implements Initializable {
  
      @FXML
      private TextField name;
  
      @FXML
      private TextField description;
  
      @Override
      public void initialize(URL url, ResourceBundle resourceBundle) {
      }
  
      public void save(){
          final AtomicLong identifier = new AtomicLong(5);
          Long id = identifier.incrementAndGet();
          String catgoryName = name.getText();
          String categoryDescription = description.getText();
  
          Category category = new Category(id,catgoryName,categoryDescription);
  
          ReadingDataFromFiles.writeCategory(category);
  
      }
  }
  </code></pre>
  <p>When the programs runs there's a screen to add a new category and the user has to write category's name and description but ID should be automatic and should be increased every time the user enters a new Category. The way I've done it doesn't work as intended, it's increased only once but since initial value stays 5 it's always 6.</p>