Skip to content
Advertisement

Tag: hashmap

Java – HashMap for booking system

I have been given an exercise to develop an appropriate data structure to implement a tennis court booking system. A hashmap is what is required for this and I was given a diagram as a visual representation of the data structure. From looking at the diagram, I am unclear on how the Key and Value should be defined in the

Using Streams on a map and finding/replacing value

I’m new to streams and I am trying to filter through this map for the first true value in a key/value pair, then I want to return the string Key, and replace the Value of true with false. I have a map of strings/booleans: That is where I am stuck–I might be doing the first part wrong too, but I’m

Group map values but keys are same

I have a map like this. Map<long,List<Student>> studentMap Key is a number 1,2,3,4… Student object is : What i want to do is to convert it Map<long,List<StudentInfo>> studentInfoMap object and group id, addressNo and code fields.I want key are same for both maps. I can group the map by using these codes but summingDouble is not working for BigDecimal.Also I

Suspicious call to ‘LinkedHashMap.get’

Hello I have the following code Since the Object I use as a Key is dynamically generated I have no knowledge about it so I have to find it before I can use it to get its value. This code gives me the warning Suspicious call to ‘LinkedHashMap.get’, is that a problem and how would I get rid of the

Query did not return a unique result

This is the query I have written: This is the output I am getting from the database: id versions 101 0.0 101 1.0 101 2.0 101 3.0 In my application, I am storing this result in but it gives an error saying “query did not return a unique result” How can I store this result? which data structure could I

How to filter a hashmap with specific conditions

I have the following initial hashmap: LatS=[59, 48, 59, 12, 48] LatD=[41, 42, 46, 42] EW=[W, W, W, W] NS=[N, N, N, N] LonM=[39, 23, 30, 48] State=[OH, SD, WA, MA] LatM=[5, 52, 35, 16] City=[Youngstown, Yankton, Yakima, Worcester] LonS=[0, 23, 36, 0] LonD=[80, 97, 120, 71] I want to filter the Hashmap using the method query that has the

For HashMap, is it more efficient to use compute() or put()

I have tried looking around for a while but I can’t find a concrete answer and still am having some trouble understanding exactly what the compute method for HashMap does. The way I understand it at the moment is that compute will allow you to manipulate the value but not set it to a new value (like where the garbage

Advertisement