【发布时间】:2015-02-16 19:07:13
【问题描述】:
我在调用另一个类的数组列表时遇到问题。我在其中定义了一个名为 IntBag 的类和一个 arraylist 包。在 main 方法中,我想编写一个程序,使我能够从另一个类中更改数组列表的长度。当我尝试时,出现“找不到符号”错误。你能帮忙吗?
import java.util.*;
public class IntBag
{
private static ArrayList<Integer> bag = new ArrayList<Integer>();
private int maxNumber;
public IntBag(ArrayList bag, int maxNumber)
{
this.bag = bag;
this.maxNumber = maxNumber;
}
public static ArrayList getBag()
{
return bag;
}
public int sizeArray(ArrayList bag)
{
return bag.size();
}
}
public class test
{
public static void main(String[] args)
{
Scanner scan = new Scanner(System.in);
int choice, size;
IntBag.getBag();
System.out.println("Enter the size of an array : ");
size = scan.nextInt();
bag = new ArrayList<Integer>(size);
}
}
【问题讨论】:
标签: java class arraylist calling-convention