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

java.lang.ClassCastException: com.google.gson.internal.LinkedTreeMap cannot be cast to model class android

I am passing the response of an API call (Retrofit used) to a class and trying to cast it to my model class. Since i am using retrofit for the API call, it generates a linked hashmap based on the response from the server prior to convert it into…
0
votes
1 answer

How to add multiple buttons to a tilepane?

I have a tilepane inside the center of a borderpane. For every entry in a linked hashmap I want to add a button to the tilepane. This tilepane already exists in the fxml file and has the fx:id fieldContainer. If I add a key-value pair one at a time,…
Isoldhe
  • 300
  • 1
  • 7
  • 20
0
votes
1 answer

How to update every value of the keyset in a LinkedHashMap in Scala, having a LinkedHashMap[Int, ListBuffer[Int]]?

I have a LinkedHashMap of type: var map: LinkedHashMap[Int, ListBuffer[Int]] = ((1 -> (2, 1)), (2 -> 2), (3 -> (5, 3))) I want to add an element to every list of every key, let's say i want to add "6" in order to have: ((1 -> (6, 2, 1)), (2 -> (6,…
Andrea
  • 47
  • 7
0
votes
2 answers

How to merge two LinkedHashMaps[Int, ListBuffer[Int]] in Scala?

I found this method: def merge[K, V](maps: Seq[Map[K, V]])(f: (K, V, V) => V): Map[K, V] = { maps.foldLeft(Map.empty[K, V]) { case (merged, m) => m.foldLeft(merged) { case (acc, (k, v)) => acc.get(k) match { case…
Andrea
  • 47
  • 7
0
votes
2 answers

Trying to sort a linked HashMap by value

letterFrequencies.entrySet().stream() .sorted(Map.Entry.comparingByValue().reversed()) .collect(Collectors.toMap(Entry::getKey, Entry::getValue)); I'm currently using this to try but I get an error which says The method…
KONADO
  • 189
  • 1
  • 13
0
votes
1 answer

Read data from nested LinkedHashMap

1st level linkedhashmap LinkedHashMap> level_1 = new LinkedHashMap<>(); 2nd level linkedhashmap` LinkedHashMap level_2 = new LinkedHashMap<>(); level_2.put("abcd", R.drawable.abcd); put…
0
votes
1 answer

Hashmap not receiving expected value

Sorry if this is a dumb question, I'm very new to working with maps. static void redacted(Map, List> whatComesNext, List text) { List maurice = new ArrayList(); //feeds the double string key to the…
user2709168
  • 117
  • 1
  • 14
0
votes
1 answer

Get java.lang.IllegalArgumentException: argument type mismatch for some but not all attempts to change JSON attribute value

IDE: IntelliJ IdEA 2017.2.4 Language: Groovy 2.4.11 Test Framework: Spock 1.1-groovy-2.4 New to all of the above. No prior experience in Java either. First post here and I actually read the intro and guidelines and trying my best to follow. JSON…
SleepyD
  • 39
  • 1
  • 2
  • 9
0
votes
2 answers

How To Reverse The Order Of LinkedHashMap Elements In Scala

Is there any elegant way to reverse the elements' order of LinkedHashMap in Scala? For instance, I have a LinkedHashMap[Integer, String] like: [1, "one"] [2, "two"] [3, "three"] What is the best way to get a LinkedHashMap[Integer, String] like: [3,…
0
votes
2 answers

Hash Map Sorting in java8

I have following HashMap "1": { "profilePic":null, "roleNo" : "12" }, "2": { "profilePic":null, "roleNo" : "1" } I want the output as below "2": { "profilePic":null, "roleNo" : "1" }, "1": { …
ankit
  • 25
  • 1
  • 2
  • 11
0
votes
1 answer

Why passing the load factor on specifying the access order on the constructor?

I was wondering why when does the constructor of a LinkedHashMap that the client code can specify if is access ordered expect a loadFactor? Is there any particular reason for this design instead of using a default factor?
Jim
  • 18,826
  • 34
  • 135
  • 254
0
votes
2 answers

ArrayList or Multiple LinkedHashMap

I have an ArrayList of a custom object A. I need to retrieve 2 variables from A based on certain conditions. Should I simply use for loop to retrieve data from the list each time or create 2 LinkedHashMap and store the required variable in it as…
yonikawa
  • 581
  • 1
  • 9
  • 32
0
votes
3 answers

Retain Column Order in Database Connector in Mule

How can i force the database connector to return LinkedHashMap to ensure that resultset is in same order as in db?
vijay dhanakodi
  • 175
  • 1
  • 14
0
votes
4 answers

How to display keys from Map?

I want to add x elements (just keys) from sorted map to list and display them. public static ArrayList miZrodzicowIpotomstwa(Map mapVectFunc_tmp, int x) { ArrayList listaMi = new ArrayList<>(); ArrayList
0
votes
1 answer

Return values from database queries into a LinkedHashMap

I keep getting one value from this LinkedHashMap it's either the first [ if (resultset.next()) ] or the last [ while(resultset.next()) ], only one result is coming back but I want the full map. How do I return all rows in the table that fit my…