Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: ArrayList error

  1. #1
    Junior Member
    Join Date
    Feb 2021
    Location
    GB
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default ArrayList error

    Hi,

    I have this code from a site and I tried to run it but have an error.

    package myProject;
     
    import java.util.ArrayList;
     
    public class listArray2D {
     
    	public static void main(String[] args) {
     
    		ArrayList<ArrayList<String>> groceryList = new ArrayList();
     
    		ArrayList<String> bakeryList = new ArrayList();
    		bakeryList.add("pasta");
    		bakeryList.add("garlic bread");
    		bakeryList.add("donuts");
     
    		ArrayList<String> produceList = new ArrayList();
    		produceList.add("tomatoes");
    		produceList.add("zucchini");
    		produceList.add("peppers");
     
    		ArrayList<String> drinksList = new ArrayList();
    		drinksList.add("soda");
    		drinksList.add("coffee");
     
    		groceryList.add(bakeryList);
    		groceryList.add(produceList);
    		groceryList.add(drinksList);
     
    		System.out.println(groceryList);
     
    	}
     
    }
    the error is:
    Exception in thread "main" java.lang.Error: Unresolved compilation problems:
    ArrayList cannot be resolved to a type
    Last edited by rwahdan; August 18th, 2023 at 11:32 AM. Reason: class name should start capital letter

  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: ArrayList error

    Have you solved your problem now?
    If you don't understand my answer, don't ignore it, ask a question.

Similar Threads

  1. Arraylist error
    By Techstudent in forum What's Wrong With My Code?
    Replies: 1
    Last Post: February 4th, 2014, 02:41 PM
  2. ArrayList weird display error
    By PissMaster in forum What's Wrong With My Code?
    Replies: 2
    Last Post: April 9th, 2013, 04:42 AM
  3. [SOLVED] error with equals in arraylist loop
    By Randor in forum Loops & Control Statements
    Replies: 2
    Last Post: November 27th, 2012, 10:46 AM
  4. ArrayList problem, help me to find out the error!
    By jinanzhaorenbo in forum Exceptions
    Replies: 1
    Last Post: July 30th, 2012, 10:55 PM
  5. [SOLVED] I don't know why this error using get() method from the ArrayList class
    By juanp_1982 in forum What's Wrong With My Code?
    Replies: 4
    Last Post: February 11th, 2012, 03:11 PM

Tags for this Thread