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

Thread: Array List; How to pass objects into another arraylist

  1. #1
    Junior Member
    Join Date
    Aug 2011
    Posts
    4
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Array List; How to pass objects into another arraylist

    I'm supposed to compare objects within a list to a given value and then pass them to another list if the values tally. But the code does not compile; javac says cannot find symbol

    public class Librarian {
    private ArrayList<Book> bookList;

    public Librarian () {
    bookList = new ArrayList<Book>();
    }

    public ArrayList<Book> findBooksWrittenBy(ArrayList<Book> inputList, String author) {
    ArrayList<Book> authorList = new ArrayList<Book>();

    for (int position = 0 ; position < inputList.size() ; position++ ) {
    Book temp = inputList.get(position);
    String bkAuthor = temp.getAuthor();
    if (bkAuthor.equalsIgnoreCase(author)) {
    authorList.add(temp);
    }
    }
    return authorList;
    }


    }


  2. #2
    Grand Poobah
    Join Date
    Mar 2011
    Posts
    1,545
    My Mood
    Grumpy
    Thanks
    0
    Thanked 167 Times in 158 Posts

    Default Re: Array List; How to pass objects into another arraylist

    We don't read minds. Copy and paste the exact error message.
    Improving the world one idiot at a time!

  3. #3
    Junior Member
    Join Date
    Aug 2011
    Posts
    4
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Re: Array List; How to pass objects into another arraylist

    Error.jpg

    there's the errors

  4. #4
    Think of me.... Mr.777's Avatar
    Join Date
    Mar 2011
    Location
    Pakistan
    Posts
    1,136
    My Mood
    Grumpy
    Thanks
    20
    Thanked 82 Times in 78 Posts
    Blog Entries
    1

    Default Re: Array List; How to pass objects into another arraylist

    1. Enclose the code in the code tags.
    2. Format code properly, use some editor.
    3. Is this your whole code?????
    If yes, i will recommend you to read tutorials. If no, i will suggest to read forum rules.

    Thanks

Similar Threads

  1. Can I pass character array to new method?
    By harrydb11 in forum What's Wrong With My Code?
    Replies: 1
    Last Post: September 21st, 2011, 01:56 PM
  2. Conditional statements on Array list objects
    By jaguarpaw in forum Collections and Generics
    Replies: 3
    Last Post: May 10th, 2011, 09:52 AM
  3. Pick random objects from array/arraylist. Newbie.
    By Sputnik in forum Collections and Generics
    Replies: 3
    Last Post: October 29th, 2010, 11:59 AM
  4. How do you pass an Array as a Parameter?
    By Arius in forum Java Theory & Questions
    Replies: 1
    Last Post: January 23rd, 2010, 09:36 PM
  5. Arraylist Objects to Database
    By frankycool in forum JDBC & Databases
    Replies: 3
    Last Post: November 15th, 2009, 08:01 PM

Tags for this Thread