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
1 answer

Flutter: Why LinkedHashMap..addAll replaced all old data instead of append

sample list: _events = [{ "name" : "A", "date" : "15 jun" }, { "name" : "B", "date" : "15 jun" }, { "name" : "C", "date" : "17 jun" }, { "name" : "D", "date" : "17 jun" },] kEvents = LinkedHashMap>(equals: isSameDay,…
icantcode
  • 142
  • 1
  • 15
-1
votes
3 answers

Linked Hash Map counter not properly incrementing

Trying to "compress" a string by replacing duplicate characters with numbers (For example, the string aabcccccaaa would become a2blc5a3). I tried to use a Linked HashMap to solve the problem because the input order needs to be preserved, but the…
user12207727
-1
votes
1 answer

How to put data in the map that in the another map?

I faced the difficulties when I try to add the cases number into each date of each country. In my attempt, it will only add the whole list of the record in each date of each country Below is the output of the List>…
mike kong
  • 47
  • 7
-1
votes
1 answer

get the highest version number for the id from arraylist in java

I have a arraylist which contains these values: ArrayList list= new ArrayList<>(); list.put("A101","2020_1.0"); list.put("A101","2020_3.0"); list.put("A101","2020_2.0"); list.put("A102","2020_2.0"); list.put("A102","2020_1.0"); I…
-1
votes
1 answer

Why the order of the data returned by the ajax call interface is not correct?

The order of the data returned by the ajax call interface is incorrect. If the key is a string, it is correct, and the key is in a numerical order. The data returned by the postman call interface is correct. { "3": "3#", "4": "4#", …
-1
votes
1 answer

LinkedHashMap: replace method fails to replace value for spacified key

I have a linked hash map which stores random 6 char string as a key and 30 char string as values. When I call replace method, it is supposed to replace value for given key and return existing value associated with given key. Code Map cache = new…
kAmol
  • 1,297
  • 1
  • 18
  • 29
-1
votes
1 answer

Wrong Thymeleaf iteration

I dont know why but when i iterate a Map with thymeleaf, The index order is changing... ?
index
Yvonnick U
  • 53
  • 7
-1
votes
2 answers

ClassCastException while converting LinkedHashMap to generic class

Consider the following class : public class MsgReceiver extends AbstractMsgReceiver implements MsgReceiver { @KafkaListener( // necessary properties ) public void receiveMessage(@Headers Map headers, @Payload…
definepi314
  • 63
  • 1
  • 10
-1
votes
2 answers

Mapping char array 2 by 2 character

I have a character array like XXYYXYXYXZXZXZXYXX and I want to map it to LinkedHashMap two by two characters as shown below: public LinkedHashMap convert(char[] array) { LinkedHashMap map = new…
user5871859
-1
votes
1 answer

Getting Data from Arraylist and input into put method of LinkedHashMap

i have this function below which takes in a arraylist of Strings and return a LinkedHashMap. I plan to use this linkedhashmap to write into a textfile subsequently. public Map convertMap(ArrayList Data){ …
MrAverage
  • 3
  • 1
-1
votes
2 answers

How to make the value of a map blank while comparing it with the values of another map?

Suppose I had a two maps region1, region2 and both are declared as LinkedHashMap> region1 = new LinkedHashMap<>(); LinkedHashMap> region2 = new LinkedHashMap<>(); region1 contains the below…
Karthik
  • 145
  • 1
  • 2
  • 12
-1
votes
5 answers

Why LinkedHashMap can't sort HashMap while TreeMap can?

I'm trying to sort HashMap's output using LinkedHashMapand TreeMap. When I use TreeMap to sort out HashMap it works like a charm. Map hMap = new HashMap(); hMap.put(40, "d"); hMap.put(10,…
Dil.
  • 1,996
  • 7
  • 41
  • 68
-1
votes
1 answer

class Double is abstract; cannot be instantiated in scala

object demo { def main(args:Array[String]):Unit= { val temp: LinkedHashMap[String,Object]=new LinkedHashMap[String,Object]() temp.put("apple", new Double(1)); // here i received error since double is abstract class and…
-1
votes
2 answers

LinkedHashMap access by index vs Performance

I would like to discuss a bit of performance of a particular collection, LinkedHashMap, for a particular requirement and how Java 8 or 9 new features could help on that. Let's suppose I have the following LinkedHashMap: private Map
skinny_jones
  • 470
  • 1
  • 5
  • 12
-1
votes
3 answers

get the key by comparing value in LinkedHashMap

I made an Custom Class which name is (ObjClass). I insert Custom Class name instead of value in LinkedHashMap. Like the following: LinkedHashMap map = new <> LinkedHashMap; I have following getter and setter in ObjClass, there names are private…
naeem
  • 43
  • 8