I need to create an empty list in one method and save the reference. Then, I need to pass the reference to another method where the list is populated with shapes and their parameters.
public class Test {
public static void start() { ArrayList<Object> shapes = new ArrayList<>(); } public static void create() { BufferedReader file = new BufferedReader(new FileReader("dataFile.txt")); if (file.readLine() == "Rectangle") { String shapeType = file.readLine(); String name = file.readLine(); Double length = Double.valueOf(file.readLine()); Double width = Double.valueOf(file.readLine()); Rectangle newShape = new Shape.Rectangle(name, length, width); shapes.add(newShape); // this is where this class cannot recognize "shapes" list
New contributor