I have a problem with calling an arraylist from another class. I defined a class called IntBag and an arraylist bag in it. In the main method I want to write a program which enables me to change the length of the arraylist from the other class. When I try I get a "cannot find symbol" error. Could you help?
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);
}
}