I am adding data into HashMap where node is an object with variables index and successor.
private static HashMap <Integer, node> peerList = new HashMap<Integer, node>();
public void generateFingerTable (int node_position) {
            chordSize = chord.initChordSize;        
            chord chord = new chord();  
        //create new node and add to map
        node newPeer = new node();
        peerList.put(node_position, newPeer);
        for (int i=0; i<chordSize; i++) {
            int temp = i+1;
            newPeer.index = new int [chordSize];
            newPeer.successor = new int [chordSize];
            int temp1 = node_position + (int)Math.pow(2, temp-1) % chord.getChordSize();
            peerList.get(node_position).index[i] = temp;                
            peerList.get(node_position).successor[i] = temp1;
            System.out.println ("Index: "  + newPeer.index[i] + "\n" + "Successor: " + 
                    newPeer.successor[i]);          
        }
}
public void printFingerTable() {
        for (Map.Entry<Integer, node> m : peerList.entrySet()) {
            System.out.println ("Peer " + m.getKey() + " with Index: " + m.getValue().getIndex() + " Successor: " +
                                    m.getValue().getSuccessor());
        }
When I print the Hash details, the result shows Index: [0,0,0,0,5] , Successor:[0,0,0,0,16] which means the previously added elements gets replaced and only the last element is saved in Hashmap.
The intended result should be Index [1,2,3,4,5], Successor: [1,2,4,8,16]. How can I amend this so the data don't get replaced?
 
     
     
    