2012-07-20 210 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不支持多態。