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

HashMap not getting sorted by value

I have a HashMap which needs to get sorted by value and not key, in descending order. To get the hashmap, I determine if the given input line is an sql statement, find its complexity and then create a hashmap with key as the sql statement and value…
Apoorva
  • 1
  • 3
-1
votes
1 answer

Hashmaps: Trying to append Strings to a String List value

Sorry if this is a dumb question, I'm very new to working with maps. (Removed most of original post because I completely misunderstood what I was supposed to do.) static void learnFromText(Map, List> whatComesNext,…
user2709168
  • 117
  • 1
  • 14
-1
votes
1 answer

Putting response from the server into recylerView using AsyncTask

I am trying to put data that is fetched from server using restTemplate and AsyncTask into recyclerView. In the following code of MainActivity, I am checking server_response and it is showing correct size of server response, means upto getting data…
-1
votes
1 answer

Multiple Map values and I want to return those 3 map values in a single object

Map map1 = new LinkedHashMap map2= new LinkedHashMap(); Map map3 = new LinkedHashMap(); //dynamic…
Tatkal
  • 568
  • 4
  • 9
  • 29
-1
votes
1 answer

Get map key based on index

I want to get a LinkedHashMap key based on index. I have tried this and used a LinkedHashMap implementation instead of HashMap implementation to preserve order of insertion. I have used below code (from some SO post I can't seem to find) to get Key…
Shubham A.
  • 2,446
  • 4
  • 36
  • 68
-1
votes
1 answer

Count number of occurances using LinkedHashMap

I need to count number of occurences of the same strings in txt file. What I have come up with is public class CountWords { public File file; public Scanner scan = null; public LinkedHashMap list = new LinkedHashMap<>(); public…
Yun8483
  • 27
  • 4
-1
votes
1 answer

How to read values of a key with start and end limit in Hashmap?

I am having HashMap testmap; Which is having data with multiple keys this way, { status = [1, 2, 3, 4, 5], data = [ [1, 2, 3, 4, 5, 6], [7, 8 9, 10, 11, 12], [13, 14 15, 16, 17, 18], [19, 20, 21, 22, 23, 24], …
Sandy
  • 313
  • 1
  • 8
  • 23
-1
votes
1 answer

concurrent modification exception linked hash map android

I am using iterator to delete item from linked hash map but getting concurrent modification exception Iterator it = linkedMap.keySet().iterator(); while (it.hasNext()) { java.lang.Integer key = it.next(); if…
-1
votes
2 answers

How to loop through ArrayList that has LinkedHashMap ?

My servlet generates and sends an array to jsp. How can I achieve the following result: If item = "dress", print.out "blue dress, size: medium" Servlet part: ArrayList> listData = new ArrayList
Myroslav Tedoski
  • 301
  • 3
  • 14
-1
votes
1 answer

Sort LinkedHashmap of Array in ascending and descending order - Java

How do I sort a LinkedHashMap of int arrays, by having the first element in the array sorted in descending order, and the second element sorted in ascending order? e.g. No. Vol. Rank becomes No. Vol. Rank 1 4 2 …
-1
votes
3 answers

In my Java program, I get NullPointerException in my HashMap even after initialising and putting values to the HashMap

In my Java program, I get NullPointerException in my HashMap even after initialising and putting values to the HashMap. LinkedHashMap ft = new LinkedHashMap(5); ft.put( (short) 1, BigInteger.valueOf(A)); …
-1
votes
1 answer

How to iterate a LinkedHashMap using index variable in JSTL

Can you please suggest how to iterate a LinkedHashMap using index variable. It important to that I use index variable to iterate the map. I need the index to access the value somewhere else in the same map Map> map = new…
-1
votes
1 answer

how to sort linkedhashmap based on key . Here I used an object as a key

I am using the linked hashmap to populate values in expandable list .I successfully populate them. Here key is the menuitems and values are corresponding modifiers I places two buttons foe increasing and decreasing quantity of menu items .As it is…
-1
votes
4 answers

Does the LinkedHashMap values collection iterate in insertion order?

Does the LinkedHashMap values collection iterate in insertion order? Does the LinkedHashMap values collection ( linkedHashMap.values() ) iterate in insertion order? The documentation states the key set will iterate in insertion order but what about…
CodingHero
  • 2,865
  • 6
  • 29
  • 42
-1
votes
2 answers

Java - NullPointerException in array?

I'm having some bother with a string array in java. I'm trying to output an inverseNewWords LinkedHashMap value to an output file, but I keep getting an NPE for the array. For some reason the first line doesn't seem to…