I have two integer variables nbBooks and libraryId.
I am trying to print the library id and the total number of books in that library in one line.
My ideal is to get both of these variables as integers and do a loop through both, but currently I am getting nbBooks as
String
NBBooks
cannot convert from Integer to Integer []
String[] nbBooks = request.getParameterValues("nbBooks");
Integer[] libraryId = Integer.valueOf(request.getParameter("libraryId"));
for (int i = 0; i < nbBooks.length; i++) {
int NBBooks = Integer.parseInt(nbBooks[i]);
int id = libraryId [i];
System.out.println("library id is: "+ id + " total number of books is: "+ NBBooks);
}
If libraryId is String[]
String[] nbBooks = request.getParameterValues("nbBooks");
String[] libraryId = request.getParameterValues("libraryId");
for (int i = 0; i < nbBooks.length; i++) {
int totalBooks = Integer.parseInt(nbBooks[i]);
int id = Integer.parseInt(libraryId [i]);
System.out.println("library id is: "+ id + " total number of books is: "+ totalBooks);
}