2012-07-20 209 views
4

我使用BeanShell的,我想使用ArrayListBeanShell的 - 使用ArrayList的

我的代码 -

import java.util.*; 

List test= new ArrayList(); 
test.add("Last Name"); 

但我得到以下异常

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 

任何想法是什么原因造成的问题?

谢谢

+0

我测试了BeanShell本身的代码,它的工作原理。为什么异常消息包含'org.apache.bsf.BSFException' – 2012-07-20 02:26:27

+0

我正在使用Liquid Office其HP产品。我们使用beanshell和javascript。运行它的伤害。可能是这个原因? – Coder 2012-07-20 02:28:43

回答

2

您需要定义ArrayList的类型。在这里,你会做这样的:

List<String> test = new ArrayList<String>(); 
+0

我试过了。没有工作。让我在“<” :( – Coder 2012-07-20 02:22:15

+0

因此,这是用Java或Javascript – jrad 2012-07-20 02:22:59

+0

编辑语法错误:现在应该工作,我犯了一个愚蠢 – jrad 2012-07-20 02:23:27

1

尝试ArrayList test = new ArrayList(); 为我工作的罚款。 猜测BeanShell不支持多态。