Package mylib:

Library class:
Code:
package mylib;

import java.util.*;

class Library {
	static int book_index;
	static Scanner input = new Scanner(System.in);

	static void getIndex() {
		System.out.print("Enter book index: ");
		book_index = input.nextInt();
		input.nextLine();
	}

	public static void main(String[] args) {
		// Create an array of books
		Book[] myBooks = new Book[3];

		// Initialize each element of the array
		myBooks[0] = new Book("The Lover's Dictionary", "Levithan, D.", 211);
		myBooks[1] = new Book("White Tiger", "Adiga, A.", 304);
		myBooks[2] = new Book("Thirteen R3asons Why", "Asher, J.", 336);

		while(true) {
			// Print book listing
			System.out.println("\n***** BOOK LISTING *****");
				for(int i = 0; i < myBooks.length; i++) {
					Book book = myBooks[i];
					System.out.println("[" + (i + 1) + "] " + book.sTitle +
						"\nAuthor: " + book.sAuthor + "\nPages: " +
						book.iPages + "\nStatus: " + book.sStatus);
					System.out.print("\r\n");
				}

			// Select library action
			System.out.println("***** SELECT ACTION *****");
			System.out.println("B - Borrow a book" + "\nR - Reserve a book" +
				"\nI - Return a book" + "\nX - Exit program");
			System.out.print("\nEnter command: ");
			String sAction = input.nextLine();

			try {
				switch(sAction.toUpperCase()) {
					// Borrow a book
					case "B":
						System.out.println("\n***** BORROW A BOOK *****");
						getIndex();
						myBooks[book_index-1].borrowBook();
					break;

					// Reserve a book
					case "R":
						System.out.println("\n***** RESERVE A BOOK *****");
						getIndex();
						myBooks[book_index-1].reserveBook();
					break;

					// Return a book
					case "I":
						System.out.println("\n***** RETURN A BOOK *****");
						getIndex();
						myBooks[book_index-1].returnBook();
					break;

					// Exit the program
					case "X":
						System.out.println("\nTerminating program...");
						System.exit(0);
					break;

					default:
						System.out.println("\nINVALID LIBRARY ACTION!");
					break;
				}
			}
			catch(ArrayIndexOutOfBoundsException err) {
				System.out.println("\nINVALID BOOK INDEX!");
			}
			catch(InputMismatchException err) {
				System.out.println("\nINVALID INPUT!");
			}
        }
	}
}
Book class:
Code:
package mylib;

class Book {
	int iPages;
	String sTitle, sAuthor, sStatus;

	public static final String AVAILABLE = "AVAILABLE",
		BORROWED = "BORROWED", RESERVED = "RESERVED";

	// Constructor
	public Book(String sTitle, String sAuthor, int iPages) {
		this.sTitle = sTitle;
		this.sAuthor = sAuthor;
		this.iPages = iPages;
		this.sStatus = Book.AVAILABLE;
	}

	// Constructor accepts no arguments
	public Book() {
	}

	// Borrow book method
	void borrowBook() {
		if(sStatus.equals(Book.AVAILABLE) || sStatus.equals(Book.RESERVED)) {
			sStatus = Book.BORROWED;
			System.out.println("\nBORROW SUCCESSFUL!");
		}
		else {
			System.out.println("\nBOOK IS UNAVAILABLE!");
		}
	}

	// Reserve book method
	void reserveBook() {
		if(sStatus.equals(Book.AVAILABLE)) {
			sStatus = Book.RESERVED;
			System.out.println("\nRESERVE SUCCESSFUL!");
		}
		else {
			System.out.println("\nBOOK IS UNAVAILABLE!");
		}
	}

	// Return book method
	void returnBook() {
		if(sStatus.equals(Book.AVAILABLE)) {
			System.out.println("\nBOOK IS AVAILABLE!");
		}
		else if(sStatus.equals(Book.RESERVED)) {
			System.out.println("\nBOOK IS RESERVED!");
		}
		else {
			sStatus = Book.AVAILABLE;
			System.out.println("\nRETURN SUCCESSFUL!");
		}
	}
}
When I enter an invalid integer book index, say 4, the error is caught and it prints INVALID BOOK INDEX!

However, when I enter a char or string for the book index, it prints INVALID LIBRARY ACTION! when it should be printing INVALID INPUT!

The default clause appears to override the catch?