lundi 12 avril 2021

Java: How to read a private field value from another class without a getter

Can Someone help me with below code, I want to access/get the values of myConstraint from another Class?

public class myLegacyClass{

    private void methodOfInterest(){
        ValueConstraint myConstraint = new EnumerationConstraint( new int[] {1, 2, 3, 4, 5, 7, 9});
    }
}


public class myNewCode{

    public static void main(String[] args)
    {
      // read the value of myConstraint here ...
    }
}

how can I do it?

Note: I can not change my myLegacyClass and there are no getters and setters available for myConstraint





Aucun commentaire:

Enregistrer un commentaire