List<DataModel> dataList=new ArrayList<DataModel>();
for (int i = 0; i < 10; i++) {
DataModel data=new DataModel();
data.setIntData(i);
data.setStrOne("this is one "+i);
dataList.add(data);
}
Map<Integer,DataModel> dataMap = dataList.stream().collect(Collectors.toMap(DataModel::getIntData, (p) -> p));
for (Integer key : dataMap.keySet()) {
System.out.println("key= "+ key + " and value= " + dataMap.get(key).getStrOne());
}this