Questions tagged [linkedhashmap]

LinkedHashMap is a Hash table and linked list implementation of the Map interface in the Java Standard library. This implementation provides a predictable iteration order, in contrast with the unspecified ordering provided by HashMap, which is normally the order in which keys were inserted into the map.

703 questions
-1
votes
2 answers

Compare two values in a LinkedHashMap to avoid adding identical values

I have a for loop from a JSONarray and I add the values to a LinkedHashMap. I would like to avoid adding identical values. I don't know how to do this. for (int l = 0; l
Xavier
  • 270
  • 1
  • 7
  • 17
-1
votes
2 answers

Count occurrences of a String in a String[] by a Map

The following method is supposed to count the occurrences of each item in the given set: void groupBy(String[] stuff) { LinkedHashMap A = new LinkedHashMap(); final AtomicInteger one = new…
-1
votes
1 answer

sorting LinkedHashMap using IDs

I am using LinkedHashMap to read data from excel file and store them ina table in mysql! How can i sort the LinkedHashMap to store the data with descending IDs? Here is an example of my excel file: ID Name Salary 50 christine 2349000 43 …
dedmar
  • 401
  • 3
  • 12
  • 22
-1
votes
3 answers

LinkedHashMap printing formatted?

Hey I have a LinkedHashMap containing several values but I'm struggling to print it in the format I want. It will be passed a size integer, and I want it to print out the values in a square format, and if there's not a value for a certain key up to…
user2152251
  • 43
  • 1
  • 5
-1
votes
3 answers

HashMap in a HashMap

Updated:- Problem Statement is- I need to store these things- For ID corresponding to 1, I need to Store these things - Key CGUID(String CGUID) and its Value, Key SGUID(String SGUID) and its Value, Key PGUID(String PGUID) and its Value, Key…
AKIWEB
  • 19,008
  • 67
  • 180
  • 294
-1
votes
4 answers

java position of in linkedhashmap

I have been searching for hours through all the posts regarding LinkedHashMap but I seem to be missing the basics. I will be generating a K,V sets from a db call, but no idea what each set will be. Some K,V will be processed and others not I need…
art vanderlay
  • 2,341
  • 4
  • 35
  • 64
-2
votes
1 answer

How to merge duplicates values from Map and create a Map>

Given a map of Person and Dog: LinkedHashMap personDogMap = new LinkedHashMap<>(); The classes for Person and Dog: class Person { String name; String id; int age; //getters } class Dog { String name; int age; //getters } How can I…
Branis
  • 17
  • 3
-2
votes
1 answer

Sum up values of object in Array List (Java)

I have key/value like this ("A", 2.2); ("A", 1.1); ("B", 4.0); ("B", 2.0); ("C", 2.5); ("A", 2.0); ("A", 2.2); ("A", 1.0); I expect to have result is A=3.3 B=6.0 C=2.5 A=5.2 I tried with code static LinkedHashMap map =…
Parabol
  • 63
  • 8
-2
votes
1 answer

How do I access nested hashmap java

I've a Map response = { sendResponse = { return = { SendResponse = { txnID = 4fa160ce-638f-4556-9313-afbef543fadd, emailTypeID = 1020261131, txnStatusCode = 1, …
MyUser12
  • 13
  • 3
-2
votes
3 answers

Linked HashMap - Iteration (Java)

I'm trying to iterate through a Linked HashMap keySet however I am having difficulties in getting it to work. Essentially I am searching the keySet to find a word, and another word. If the second word is immediately after the first word I wish to…
-2
votes
1 answer

java.lang.ClassCastException: org.springframework.util.LinkedCaseInsensitiveMap while reading and setting list contents into domain object

I am working in spring batch application. I need to get the list of elements from ItemWriter object and set it each list into respective domain object and save it to Mongo DB. But when I am get trying to get a list from profile object from writer,…
escort
  • 147
  • 1
  • 1
  • 10
-2
votes
1 answer

I'm not understanding why my hashTable is not working properly C

I am creating a HashTable in C that uses a Node double pointer and using separate chaining to resolve collisions, but when I run my code it does not place collisions into the linked list. HTable *createTable(size_t size, int (*hashFunction)(size_t…
-2
votes
1 answer

Removing elements from a map of type (Int, ListBuffer(Int))

I have LinkedHashMaps of type: val map1 = LinkedHashMap(1 -> 1, 2 -> (1,2), 3 -> (1,2,3)) val map2 = LinkedHashMap(2 -> 2, 3 -> (2,3), 5 -> (2,3,5)) where the integers are nodes's ids of a graph, and the list is the path to that node. I want to…
Andrea
  • 47
  • 7
-2
votes
1 answer

Sort Java Map based on values in another map

As an input, I have List of objects, each object has name and map: 1) Name: m1 Map: {"c1": 3, "c2": 24 "c3": 12} 2) Name: m2 Map: {"c1": "A", "c2": "B", "c3": "C"} 3) Name: m3 Map: {"c1": 3.4, "c2": 4.6, "c3": 12.3} What I need as an…
Bilberryfm
  • 507
  • 2
  • 11
  • 28