Implemented a stack using Java generics.