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
3 answers

Is a EJB Singleton synchronized?

I have implemented a kind of caching bean to cache data objects as an EJB Singleton. I wonder if this is the correct way in EJB: @Singleton public class MyCache { int DEFAULT_CACHE_SIZE = 30; int DEFAULT_EXPIRES_TIME = 60000; long…
Ralph
  • 4,500
  • 9
  • 48
  • 87
0
votes
1 answer

How to retrieve value from LinkedHashMap using variables?

I would like to create variable which allows me to access to vary YAML structures. envFile is the YAML file contains data like: ENVNAME: MYSYS: MYSUBSYS: MYDETAIL: version: 1.0.0 path: C:\wwwroot\sys MYSYS2: …
Robert Grądzki
  • 139
  • 1
  • 2
  • 8
0
votes
1 answer

What's the proper representation of LinkedHashMap in JSON?

When I serialize my LinkedHashMap using GSON, I get {"b":"a","a":"1","c":"2"} and after deserializing I get back the elements in the right order. So everything works fine, but is there a guarantee that every tool works this way?…
maaartinus
  • 44,714
  • 32
  • 161
  • 320
0
votes
1 answer

Why the concurrent modification comes here

The following code throws the concurrent modification exception import java.util.*; public class SampleTest { public static void main(String[] args) { LinkedHashMap map = new LinkedHashMap(); …
0
votes
1 answer

LinkedHashMap from CSV not getting all entries

CSV file into variable in order. I've been trying to read a CSV file which contains two columns, a title and then a list of entries. Currently I've been using a LinkedHashMap; using the following loop to read, split and create the…
Isaac Manzi
  • 36
  • 1
  • 9
0
votes
3 answers

Getting key and value of linkedHashMap

I try to read data from csv file, save it to linkedHashMap and print it. But the thing is that I neet print key and value separately. Csv file has just 2 columns: First: email, Second: name. public class CsvReader { String CSVPath =…
Alex20280
  • 97
  • 6
0
votes
1 answer

How to replace HashMap with LinkedhashMap with streams?

Could you please help me to sort my Map? I have the following structure and I want to assemble apps under customers in a LinkedHashMap in a reversed order by value. [{ "CUSTOMER_1": { "APP_1": "1" }, "CUSTOMER_2": { "APP_1": "2", …
Pasha
  • 1,768
  • 6
  • 22
  • 43
0
votes
0 answers

How to iterate through bucket in LinkedHashMap?

I would like to iterate through all the values in every bucket in the following linkedhashmap LinkedHashMap test in order to get to an arraylist of the following type List> So that all the integers in the same bucket…
0
votes
3 answers

How do i compare a value in one hashmap to the same value in another hashmap?

Good morning, Sorry if this has already been asked but i'm stuck on a java project that I'm building. It is a program that allows the user to insert a bet (for example the predicted result of a sports match) and at a later time allows an user to…
JB1989
  • 35
  • 6
0
votes
1 answer

How to sort map of object on the basis of date

How to sort map on the basis of time field in object. My Map looks like: Map -> ShiftDTO consist of following key: shiftName, shiftStartTime, shiftEndTime. shiftStartTime is of type Date, and I want to sort on the basis of date in…
Srishti
  • 355
  • 1
  • 17
0
votes
0 answers

One main LinkedHashMap for all clients

I have a ServerMain class with ServerThreads. Everytime a client connects 1 new ServerThread is created. I want that every client send a string[] containing a port and coords that are saved in a LinkedHashMap and then the server should send the…
kris
  • 1
  • 1
0
votes
1 answer

LinkedHashMap size doesnt change

I'm trying to .put a pair into a linkedhashmap but when i put 2 or more the size never changes! When i iterate it i get every pair but in random order but the size stays 1. When i hard code the .put (example playerCoords.put(1,"test")) the size…
kris
  • 1
  • 1
0
votes
2 answers

How to print a list of maps with each map entry in a seperate line

I want to print a array list, in that array list it contains hash map and I print in a text file. while trying to print the text file it print in single line. I need in a separate line Example: ArrayList mainlist= new…
Syed Ali
  • 5
  • 4
0
votes
5 answers

How to print a arrayline in seperate line in a TEXT FILE

I have to print a Array List in a text file. I need a output in separate line but I got in same line. Example: My expected output in text file: bat ball …
Syed Ali
  • 5
  • 4
0
votes
1 answer

How LinkedHashMap maintains order if two or many objects get stored in the same index

How LinkedHashMap maintains order if two or many objects get stored in the same index If two elements in the linkedlist finds same hash code then they will get store in the same index but different nodes . this case how it would find the correct…