我使用的是beanshell,我想使用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
你知道是什么导致了这个问题吗?
谢谢
发布于 2017-07-05 22:42:42
试试在我身上运行得很好的ArrayList test = new ArrayList();
。我猜BeanShell不能与多态性一起工作。
发布于 2012-07-20 10:19:33
您需要定义ArrayList的类型。在这里,你可以这样做:
List<String> test = new ArrayList<String>();
https://stackoverflow.com/questions/11571969
复制相似问题