3/13 Creating an ArrayList Fix


#1

I was having an issue creating an ArrayList on 3/13. It told me that it could not find the symbol ArrayList. The fix for this is to write import java.util.ArrayList; at the top of the file. Your code should look like this:

import java.util.ArrayList;

public class Temperatures {

    public static void main(String[] args) {

        ArrayList<Integer> weeklyTemperatures = new ArrayList<Integer>();

    }
}

import java.util.ArrayList; us telling Java that you want to use the ArrayList class, so it includes the code for ArrayLists with your program. If you don't tell Java that you want to use ArrayList, it won't know what you're talking about when you try to use it.


#2

I am getting an error message asking if I have created the object 'weeklyTemperatures' have I not done this inside the main method? I do see it is within the brackets and the class is Interger and the Object is weeklyTempertures.

import java.util.ArrayList;

public class Temperatures {

public static void main(String[] args) {

ArrayList<Interger> weeklyTemperatures = new ArrayList<Integer>();




}

}


#4

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