user3371303
user3371303

Reputation: 43

executing loops in Beanshell interpreter

I have a string, srcCode, that contains

"HashSet hs = new HashSet();
   int i=0;
   for(i=0;i<10,i=i+2){
    hs.add(i);
    }"

using BeanShell interpret, am trying to interpret it, below is the code:

bsh.set("hs", hs);
bsh.eval("import java.lang.String;");
bsh.eval(srcCode);

its giving me error, "line 2 column 11 encountered EOF" Can that be acheived using the BeanShell interpreter?

Upvotes: 0

Views: 423

Answers (1)

Jigar Joshi
Jigar Joshi

Reputation: 240956

fix for loop syntax, you are missing ;

for(i=0; i<10; i = i + 2) {

Upvotes: 1

Related Questions