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

LinkedHashMap with values as a vector being overwritten

When I wrote this piece of code due to the pnValue.clear(); the output I was getting was null values for the keys. So I read somewhere that adding values of one map to the other is a mere reference to the original map and one has to use the clone()…
serendipity
  • 852
  • 13
  • 32
-2
votes
1 answer

How to multiply two values with the same key name from different linkedHashMaps?

I have two linkedHashmaps which are the same length with the same key names but the values are different. for example : Map map1= new LinkedHashMap(); map1.put("A", 2.3); map1.put("B", 6.1); map1.put("C",…
-2
votes
1 answer

LinkedHashMap serialization/deserialization

I have a Map map = new LinkedHashMap>(); I was added elements in this order : map.put(32,List Of SomeObjects); map.put(2,List Of SomeObjects); map.put(3,List Of SomeObjects); after invoking this…
Chala
  • 587
  • 1
  • 5
  • 11
-2
votes
2 answers

Move Selected elements of a Map up or down

I am trying to modify a list of elements in a Map by moving the selected items up or down. My idea is to remember the elements next to selected items. Because the elements are in a map, I find it much difficult to do it though I use a LinkedHashMap…
-2
votes
2 answers

comparator for LinkedHashMap

i am making a program to read data from excel files and store them in tables. But since I am new to Comparators in Java i have difficulties in making one of them. Here is my issue, I have managed to read all the data from excel files as a string and…
dedmar
  • 401
  • 3
  • 12
  • 22
-3
votes
1 answer

Convert a HashMap to JSON String using only built-in methods with Java 8

I have a json options options = { "access": "public" } Have made it in java using Hashmap, as shown below: Map options = new LinkedHashMap(); options.put("access", "public"); Now I want to convert this to json…
himan
  • 19
  • 1
  • 6
-3
votes
1 answer

I'm not getting the correct key for the value in my code using LinkedHashMap

Hi so I'm stuck here please if someone could help me please I try to explain here the best I can. Code is working fine but it's false. So I highlighted down (in bold) in the example where the problem is and commented in yellow what should be right…
devy
  • 1
  • 1
  • 2
-3
votes
1 answer

How to put String and Integer elements in LinkedHashMap with IntStream?

I am new to LinkedHashMap and I want to put elements in my Map with IntStream instead of filter.put("1", 1)... Is there any way to do it? private Map filter = new LinkedHashMap<>(); @PostConstruct public void…
user6941415
-3
votes
2 answers

Greedy algorithm broken implementation

I'm trying to implement a greedy algorithm below, So I'm trying to follow the gist of the algorithm details, but I'm getting an error at my IF statement: java.lang.IndexOutOfBoundsException: Index: 4, Size: 4 Does anyone know if the below method…
Josh123
  • 157
  • 3
  • 13
-3
votes
1 answer

Iterating over a key set of a LinkedHashMap

is it possible to retrieve the next (next, as in the next key value which has been inserted) key value of a LinkedHashMap? E.g. the current key value is 2 and the next key value is 4. I want to use the value of the next key without setting my…
optional
  • 2,504
  • 4
  • 18
  • 30
-4
votes
2 answers

LinkedHashMap searching

I have a class class polygon { private String name; private int quantity; // default constructor private polygon() { } public String get name() { return name; } public void setname(String name) { …
H'H
  • 1,638
  • 1
  • 15
  • 39
-5
votes
1 answer

TreeMap and LinkedHashMap classes

I found a Java question J couldn't understand what should be answer The TreeMap and LinkedHashMap classes: enable iteration of a map's entries based on the insertion order of elements only. enable iteration of a map's entries based on natural…
SidJj
  • 142
  • 1
  • 1
  • 11
-10
votes
6 answers

NullPointerException in LinkedHashMap

I'm creating a game. When I'm reading a LinkedHashMap, it gives me an NPE. I fill LinkedHashMap hm like this: for (String s : line.split("")) { if (s.contains("*")) { hm.put(new Coordinates(xa-32, ya), "gray"); } else if…
Zygimantas
  • 33,165
  • 6
  • 21
  • 23
1 2 3
46
47