Im trying to create an ArrayList of LinkedLists.
I want to create an ArrayList of n elements. N is a number the user inputs. Each element of the ArrayList will have a LinkedList of size n. Once the linked lists are created I'm suppose to input data. Can someone please guide me through the process? I have provided what I have coded so far, please take a look and if something is wrong, I'd appreciate the feedback.
3 Replies
⌛
This post has been reserved for your question.
Hey @Lord.Yin! Please useTIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here./close
or theClose Post
button above when your problem is solved. Please remember to follow the help guidelines. This post will be automatically closed after 300 minutes of inactivity.
As far as my understanding on your question. It seems your trying to create an ArrayList that contains N number of LinkedList objects, where each LinkedList has the same size of N. If my understanding is correct, then please do the following changes to your code.
First create N number of Linkedlists and add those to the ArrayList.
ArrayList<LinkedList<String>> arrayList = new ArrayList<>();
Then iterate the arrayList and add values using nested for loop
This message has been formatted automatically. You can disable this using
/preferences
.💤
Post marked as dormant
This post has been inactive for over 300 minutes, thus, it has been archived.
If your question was not answered yet, feel free to re-open this post or create a new one.
In case your post is not getting any attention, you can try to use /help ping
.
Warning: abusing this will result in moderative actions taken against you.