I've a below class
public class OtherString {
private String underlyingString;
public OtherString(String inp) {
this.underlyingString = inp;
}
public String checkAplhaNumeric(String underlyingString) {
String pattern= "^[a-zA-Z0-9]*$";
return this.underlyingString.matches(pattern) ? "Y" : "N";
}
public String checkInteger(String underlyingString) {
String pattern= "^[0-9]*$";
return this.underlyingString.matches(pattern) ? "Y" : "N";
}
public String checkString(String underlyingString) {
String pattern= "^[a-zA-Z]*$";
return this.underlyingString.matches(pattern) ? "Y" : "N";
}
}
Is there any way I could decide method to be called at run time for OtherString instance ?
For example:
If String methodName = checkInteger;
then call otherStringInstance.checkInteger(inp);