Please use [highlight=java][/highlight] when posting code snippets to preservse formatting.
Also in regards to your problem, you have been very vague, we need to know what you already know about this problem and which bit of the logic you are getting stuck on. Saying you don't know how to implement insertion into a linked list isn't a valid problem for us to solve, as in effect we would just be completing your homework for us. Please have a read about linked lists, how they work and then most your understandings of the logic and your code attempt at the solution. Then we can prodive you with help regarding the problem at hand.