0

I tried to do something like this but becasue getCondition will return me a string value the If statment throws error because it expect to have a boolean value.. is there is any way to retrieve and execute the String inside the if statment?

Private String condition = "age < 18";
String getCondition(){return this.condition;}

if(getCondition())
{....}
Maryam
  • 1,043
  • 1
  • 12
  • 16

1 Answers1

0

Have you tried looking here

Is there an eval() function in Java?

https://docs.oracle.com/javase/8/docs/api/javax/script/ScriptEngine.html

Community
  • 1
  • 1
Adrian Muljadi
  • 168
  • 1
  • 15