最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

java - Beanshell - using arraylist - Stack Overflow

programmeradmin3浏览0评论

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
Add a ment  | 

2 Answers 2

Reset to default 3

Try 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>();
发布评论

评论列表(0)

  1. 暂无评论