Q:

how to push emement of hashmap in stack

recently i am trying to push the hashmap element in the stack in java but every time i push the new element in the stack then all the elements in the stack is replaced with the recently pushed element. 
here is my code:
state.previousState = dotPosColor;
state.pushState();
state.getElement();
public void pushState(){
    undos.push(previousState);
    Log.d("test","First->"+undos.firstElement().toString());
    Log.d("test","Last->"+undos.lastElement().toString());
    redos.clear();
}

A:

recently i am trying to push the hashmap element in the stack in java but every time i push the new element in the stack then all the elements in the stack is replaced with the recently pushed element.

I'm going to use my crystal ball and tell you that you are declaring your intermediate variable globally, when it needs to be local. ie:
for( some loop stuff here )
{
    Object o = hashMap.get("fwerin");
}

