Judging from the name of the class, that example would come from Chapter 6 of whatever book you're reading. Doesn't the book have an explanation of what that code is supposed to do? Which lines are you not clear about?
I often find that such convoluted code is easier to handle if you write all the variables on a sheet of paper, following their values' changes as you run through the program. It is unfortunately poor quality code, the likes of which are usually only seen in certification exam preparation books.
Look! I laid an egg! Why does it smell like that? Tiny ad, does this smell weird to you?