Please tell me how to get the elements of a generic stack without popping a element?

The class I’m using is :
Stack stack = new Stack<>();

you can go through this: