Is it possible to call a method multiple times in a row and pass in different arguments each time, but without repeating the method name when calling?
For example, in JavaFX, you can add nodes to another node by calling the getChildren.add() method of the parent node each time:
GridPane gridPane = new GridPane();
Button button = new Button();
Label label = new Label();
Checkbox checkbox = new Checkbox();
gridpane.getChildren.add(button);
gridpane.getChildren.add(label);
gridpane.getChildren.add(checkbox);
As you can see, it can get quite repetitive. Is it possible to make the calls without repeating the method name? I would like to know if I could do something like:
GridPane gridPane = new GridPane();
Button button = new Button();
Label label = new Label();
Checkbox checkbox = new Checkbox();
gridPane.getChildren.add {
button;
label;
checkbox;
}
Please note that I am not suggesting the syntax above to be added into the Java language. It was just written to help clarify my point.