That's when debugging comes to the rescue If you are using an IDE, you could try to debug step by step to see what's going on in the getFirstName method. Or you could simply add a System.out.println("["+author+"]"); before calling indexOf.

Thanks The exception is giving you valuable information, especially the place where something went wrong (you may have different line numbers) Exception in thread "main" java.util.InputMismatchException at java.util.Scanner.throwFor(Scanner.java:819) at java.util.Scanner.next(Scanner.java:1431) at java.util.Scanner.nextInt(Scanner.java:2040) at java.util.Scanner.nextInt(Scanner.java:2000)at TestIndex.main(TestIndex.java:59)

This brings us to the following line :

You are trying to read a number, altough it's a string (book title ?) that comes after the author. How do you describe one line of data ? For example "0321479270_Tony Gaddis_Starting Out with Java: From Control Structures through Objects_3_AW_16_98.00". ISBN, author, title,... . You have to clear this first. Understand what your data is, and then write the code. Also, always use the information given ni a stack trace when an exception is thrown. [ April 15, 2008: Message edited by: Christophe Verre ]