How to map the key of one hashmap to another hashmap when both the key having same value

Viewed 30

I have one list of hashmap and another hashmap. The data from first hashmap I am getting data from db and printing the resultset in a list of Hashmap. Here is the code

public List<HashMap<String, String> resultSetToArrayList(ResultSet rs) throws SQLException{
ResultSetMetaData md = rs.getMetaData();
  int columns = md.getColumnCount();
  List<HashMap<String,Object>> list = new ArrayList<HashMap<String,String>>();
    while (rs.next()) {
        HashMap<String,Object> row = new HashMap<String, Object>(columns);
        for(int i=1; i<=columns; ++i) {
            row.put(md.getColumnName(i),rs.getString(i));
        }
        list.add(row);
    }
    return list;
}

2nd hashmap I am retreiving as list of webelements and storing in the hashmap. I am using Java and Selenium. If I want to map keys of first hashmap to another key of second hashmap. How to do that? This is my first post. Hoping to get positive response.

0 Answers
Related