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 3 of 3

Thread: Populating a LinkedList in java

  1. #1
    Junior Member pyler's Avatar
    Join Date
    Sep 2012
    Posts
    23
    My Mood
    Busy
    Thanks
    3
    Thanked 2 Times in 2 Posts

    Unhappy Populating a LinkedList in java

    I have a LinkedList class that implements a game
    I want to create a list and populate it when a LinkedList object is created
    The game constructor takes a word

    My general/basic question is;
    How do you populate a LinkedList of any type
    for example suppose I have a LinkedList of the Integer type,
    How do I fill it up with 10 integers?


  2. #2
    Member andbin's Avatar
    Join Date
    Dec 2013
    Location
    Italy
    Posts
    443
    Thanks
    4
    Thanked 122 Times in 114 Posts

    Default Re: Populating a LinkedList in java

    Quote Originally Posted by pyler View Post
    My general/basic question is;
    How do you populate a LinkedList of any type
    With the add method. Was this the doubt?

    Quote Originally Posted by pyler View Post
    for example suppose I have a LinkedList of the Integer type,
    How do I fill it up with 10 integers?
    With the add method, eventually in a loop if you want a contiguous range of values.
    Andrea, www.andbin.net SCJP 5 (91%) SCWCD 5 (94%)

    Useful links for Java beginners My new project Java Examples on Google Code

  3. The Following User Says Thank You to andbin For This Useful Post:

    pyler (February 18th, 2014)

  4. #3
    Junior Member pyler's Avatar
    Join Date
    Sep 2012
    Posts
    23
    My Mood
    Busy
    Thanks
    3
    Thanked 2 Times in 2 Posts

    Default Re: Populating a LinkedList in java

    Thanks

Similar Threads

  1. Populating multiple arrays with a File.
    By ccf in forum What's Wrong With My Code?
    Replies: 3
    Last Post: December 10th, 2012, 08:11 PM
  2. Replies: 26
    Last Post: December 7th, 2012, 07:58 AM
  3. Replies: 3
    Last Post: February 20th, 2012, 09:11 AM
  4. Populating a 2D array with textfield values
    By drixnak in forum What's Wrong With My Code?
    Replies: 9
    Last Post: October 19th, 2010, 01:20 PM
  5. Populating a JTable
    By crism85 in forum AWT / Java Swing
    Replies: 0
    Last Post: February 20th, 2010, 12:57 PM

Tags for this Thread