Hello everybody;
I have a problem with array in this static method
we assume we have a 100 books and their titles (I defined an array of object in the main)
and some of them have a same title
so we want to define a method that search first five books that have the title which is entered by user
and i have errors with my code
I have a problem with array in this static method
we assume we have a 100 books and their titles (I defined an array of object in the main)
and some of them have a same title
so we want to define a method that search first five books that have the title which is entered by user
and i have errors with my code
public static void findBooks (Book[] findB)//to display the first five books with the same title.
{
Scanner input = new Scanner (System.in);
int x=0;
System.out.println("Searching for first five with same title ");
findB = input..next().charAt(0);
do{
for (int i=0; i<100; i++){
if (findB[i].getTitle().equals(findB[j].getTitle()) )
findB[j].display ();
x++;
}}while (x<5);
}