Skip to content

Tag: hashmap

Hashmap – returning key and setting it as value of an object

I have two CSV files, one “crimeUSA.csv” with the headers state, city, population etc. and one StatesAbbreviations with the headers states, abbrev . First I read the “crimeUSA.csv” file and create CityCrime objects. Instead of using the state in this file, I want to match it with the s…

Using HashMap dynamically for parameter mapping in mybatis

Okay so this is kinda re-posting of this question Inserting HashMap Values to a table using ibatis (but I am looking for a different way – the answer wont work for me).. DB1GetStudentDataMapper.xml (this queries to one database) DB2InsertStudentMapper.xml (this queries to different database) DB2InsertSt…

Hasmap merge function value inside an object

I am trying to get a quantity count of products from a list of sales. So what I have is: The current way I have done it is based on this answer of integers: how to merge more than one hashmaps also sum the values of same key in java So, right now im traversing a list of sale objects,

Converting POJO into map

I have a Java class having 10 attributes, I want to convert this into 3 maps(Breaking it into 5,3,2 fields resepectively). I did some research and found that Jackson’s ObjectMapper can be used by doing something like this: This will be creating a single map for all the attributes in my POJO. What I want…