admin管理员组文章数量:1325332
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>();
本文标签: javaBeanshellusing arraylistStack Overflow
版权声明:本文标题:java - Beanshell - using arraylist - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742196272a2431138.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论