I'm very proficient in Java (MSc in Computer Science, most our courses were in Java), problem in question is very famous, we have solved it in several classes, I can fully explain you the idea, the algorithm, and the code, using text and automaton graphs (if you wish). I assure you, you'd get full understanding of the problem(s). I'll deliver explanations very quick if you pick me :)