I am trying to transfer variable from one controller to another but i am not getting correct output:
My codes:
   public class CustomControl extends AnchorPane implements Initializable {
    String customId;
    public CustomControl() {
        //if you want to set a FXML
        FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("/res/customControl.fxml"));
        //Defines this class as the controller
        fxmlLoader.setRoot(this);
        //this.getStylesheets().add("/res/style.css"); <- if you want to set a css
        fxmlLoader.setController(this);
        try {
            fxmlLoader.load();
        } catch (IOException exception) {
            throw new RuntimeException(exception);
        }
    }
        public String getCustomId() {
            return customId;
        }
    public void setCustomId(String customId) {
        return this.customId = customId;
    }
    @Override
    public void initialize(URL arg0, ResourceBundle arg1) {
          //Initializes the controller
    }
}
To set CustomId variable at other controller
CustomControl c = new CustomControl();
c.setCustomId("StackOverflow");
To get CustomId variable from other controller
CustomControl c = new CustomControl();
c.getCustomId();
System.out.Println(c.getCustomId());
It gives me output
null 
but required is
StackOverflow
And i know a same question is already asked Link So, don't mark it as duplicate
because In my question There are two controller at firstcontroller.java
 CustomControl c = new CustomControl();
    c.setCustomId("StackOverflow");
now at secondcontroller.java
CustomControl c = new CustomControl();
c.getCustomId();
  System.out.Println(c.getCustomId());
as we are getting as setting data in different controller so it gives me the output
null
please please please help me. Thank You.
 
     
    