I am using beanshell and i want to use arraylist
My code -
import java.util.*;
List test= new ArrayList();
test.add("Last Name");
But I am getting following exception
Caused by: org.apache.bsf.BSFException: BeanShell script error:Typed variable declaration :
Attempt to resolve method: add() on undefined variable or class name: test: at Line: 206
Any idea what is causing the problem?
Thanks
I am using beanshell and i want to use arraylist
My code -
import java.util.*;
List test= new ArrayList();
test.add("Last Name");
But I am getting following exception
Caused by: org.apache.bsf.BSFException: BeanShell script error:Typed variable declaration :
Attempt to resolve method: add() on undefined variable or class name: test: at Line: 206
Any idea what is causing the problem?
Thanks
Share Improve this question asked Jul 20, 2012 at 2:18 CoderCoder 3,1308 gold badges52 silver badges86 bronze badges 2-
1
I tested the code in BeanShell itself, it works. why the exception message contains
org.apache.bsf.BSFException
– LiuYan 刘研 Commented Jul 20, 2012 at 2:26 - I am using Liquid Office its a HP product. We use beanshell and javascript. Runs it tomact. May be thats why ? – Coder Commented Jul 20, 2012 at 2:28
2 Answers
Reset to default 3Try ArrayList test = new ArrayList();
That worked fine for me.
Guess that the BeanShell doesn't work with polymorphism.
You need to define the type of the ArrayList. Here, you would do it like this:
List<String> test = new ArrayList<String>();