Re: Dymanic if statement evaluation problem with string comparison
Stewart Cambridge <[email protected]> Sat, 15 May 2010 10:12:01 +0100
| Newsgroups | gmane.comp.java.beanshell.user |
|---|---|
| Message-ID | <[email protected]> |
What about using String.intern() ? On 15 May 2010 04:47, Manikandan R <[email protected]> wrote: > Hi Everyone, > > I am able to do the string comparison using eval function with string > methods something like string.equals("test"), but not able to do something > like string == "test". > > Here is the code which works fine - getting the success as output: > > String s = "test"; > > String cond = "s.equals(\"test\")"; > > Interpreter i = new Interpreter(); > > i.set("s", s); > if((Boolean)i.eval(cond)) { > System.out.println("success"); > } else { > System.out.println("fail"); > } > > Can anyone help me onhow to achieve the same using without string equals > method? > Thanks, > Mani > > ------------------------------------------------------------------------------ > > _______________________________________________ > Beanshell-users mailing list > Beanshell-users-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org > https://lists.sourceforge.net/lists/listinfo/beanshell-users > ------------------------------------------------------------------------------