How to write a program for a linkedlist without using the collection framework