[Java] Issue with passing ArrayList into constructor

Hello,

I am writing a program for storing a row of a spreadsheet. In this program, I am creating a object for each row.

The issue is that my ArrayList is causing a error:

/tmp/sub-426260014/Cereal.java:7: error: cannot find symbol
private Arraylistlist;

The instance seems to cause the error and I am not sure why.
The 5 should cast as a Integer.

import java.util.Scanner;

public class Cereal {
  public class Row {
    private int rowNum;
    private String type;
    private Arraylist<Integer>list;
    public Row(int num, String t, ArrayList<Integer>values){
      rowNum = num;
      type = t;
      list = values;
    }
  }
  public static void main(String[] args) {
    ArrayList<Integer> nums = new ArrayList<Integer>();
    nums.add(5);
    Row row1 = new Row(1, "C", nums);
  }
}

I have moved your Java question to the #general category, you accidentally added it to #javascript

My Java is a little rusty, but I think the issue is with this code:

private Arraylist<Integer>list;

Which should be:

private ArrayList<Integer> list;

note the space between the > and your property name. Also the capitalized L in ArrayList.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.