Simple question about boolean euations in JAVA

View: New views
2 Messages — Rating Filter:   Alert me  

Simple question about boolean euations in JAVA

by Glitch Machorevsky :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

How do I go from this:
String a  = "(true) || false";
to this:
System.out.println ((true) || false);
?


What I am asking is, how do I compute/parse the String so it can be calculated as a boolean expression.

THANK YOU!

PS
I have found this as a possible solution: http://jboolexpr.sourceforge.net/example.htm
However, I need something that does not involve implementing jar files and that is much much simpler. Something like:
String a = "true || false";
boolean b = (boolean) a;


Re: Simple question about boolean euations in JAVA

by rambtechit :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

String s = "true||false";
String[] vals = s.split("\\|\\|");
Object a = (Object)vals[0];
Boolean b = (Boolean)a;