Stack implemetation of java using generics