Search:

Type: Posts; User: GregBrannon

Search: Search took 0.09 seconds.

  1. Replies
    10
    Views
    1,306

    Re: How to search through values of Array?

    It's really helpful - almost necessary - to post executable code or error messages when you want help with code that "doesn't work." For example, here's runnable code using your own code that shows...
  2. Replies
    10
    Views
    1,306

    Re: How to search through values of Array?

    Your question:


    Focusing on your question, the desired method would look something like:

    private boolean[] findBookMatches( Book[] books, String title, double price )
    {
    // create a...
  3. Replies
    10
    Views
    1,306

    Re: How to search through values of Array?

    Using a for loop to create the 10 books. Here's one way:
    import java.util.Scanner;

    public class BookSearch
    {
    //Create 10 book objects with values
    private static String[] bookData...
  4. Replies
    10
    Views
    1,306

    Re: How to search through values of Array?

    Of course you can do that using a for loop (or some kind of loop). You just need to be a bit more clever. Store the data that defines each book and apply it to an appropriate constructor to create...
  5. Replies
    10
    Views
    1,306

    Re: How to search through values of Array?

    Your construction of the array that contains Book objects can be improved:

    Book[] books = new Book[10];

    Then to populate the array with Book objects, use a for loop:
    for ( int i = 0 ; i <...
Results 1 to 5 of 5