I’m really stuck on this problem.
I have several different Strings with different values and lengths like “true & true“ or “(!true & false) | true“.
Now I have to check if these statements are logically true or not. My idea was that I could somehow parse them to a boolean object and check them in an if statement.
For example:
String a = “(true & false) | true“;
if(a == true){
System.out.println(“the equation is true“);
}else{
System.out.println(“the equation is false“);
}
I already tried methods like Boolean.parseBoolean(String) or Boolean.valueOf(String).
Is there any way to do this? Or any other approach how I can solve this problem?
I appreciate the help. Thanks a lot.