You have to debug the program to figure out where its execution differs from what you expect. Recommended reading: http://www.javaprogrammingforums.com/blogs/copeg/5-debugging-system-out-println.html