Code Refactoring for collection ArrayList and LinkedList