Modified code to use generics, Added basic JavaDoc