Professional Documents
Culture Documents
LibraryArrayDifficulty Level1 - 1
LibraryArrayDifficulty Level1 - 1
int - id
String - name
String - address
Create a constructor which takes all parameters in the above sequence. The constructor should
set the value of attributes to parameter values inside the constructor.
searchLibraryById(Library[] objArray)
This method will take array of Library objects and id as input and returns the position of the id if
found or -1 if not found.
}
public static int searchLibraryById(Library[] objArr,int ID)
{
for(int i=0;i<objArr.length;i++)
{
if(ID==objArr[i].getId())
return i;
}
return -1;
}
}
class Library
{
private int id;
private String name,address;