Search:

Type: Posts; User: GregBrannon

Search: Search took 0.10 seconds.

  1. Replies
    19
    Views
    1,323

    Re: method array list

    I think you mean you're unable to transition from the pattern of asking for data, responding with results. So for Problem 1, there is no input required. The program simply outputs the book with the...
  2. Replies
    19
    Views
    1,323

    Re: method array list

    Great! Glad it worked, and good job figuring out the bs. part. I wasn't sure what object the method was being called on, and I forgot to mention it.
  3. Replies
    19
    Views
    1,323

    Re: method array list

    Where do you try to call searchForPrice()?

    I would think the code you posted might look like:
    String Price = JOptionPane.showInputDialog(null,
    "Enter a Price ");

    results =...
  4. Replies
    19
    Views
    1,323

    Re: method array list

    Remove this: "ArrayList<Book>" from that line. You don't re-declare results, just change its value(s).
  5. Replies
    19
    Views
    1,323

    Re: method array list

    Your second attempt seems correct to me, though I'm not sure why the method doesn't expect a double parameter for the max book price. Does it work?
  6. Replies
    19
    Views
    1,323

    Re: method array list

    You're right. To use methods specific to ArrayList, those not included in List, will require casting library to an ArrayList. A bit of a pain. Which should you use? Whichever you prefer. ...
  7. Replies
    19
    Views
    1,323

    Re: method array list

    Yes, or it can all be done in one line (but I'd normally initialize in the constructor):

    private List<Book> library = new ArrayList<Book>();
  8. Replies
    19
    Views
    1,323

    Re: method array list

    You will find it recommended to abstract the details of the implementation by using the following approach:
    // declaration
    List<Book> library;

    // initialization
    library = new ArrayList<Book>();
Results 1 to 8 of 8