Questions tagged as 'hashmap'

1
answer

How to add element inside an arrayList that is inside another ArrayList that in turn is inside a HashMap?

The question is: I have the Classes Student, Discipline, Note, Class. I need to add a double value in an ArrayList that is in an object of the Discipline class, but the Discipline class is inside an ArrayList and this ArrayList is inside a Ha...
asked by 19.01.2015 / 21:45
1
answer

Mapk Collection, v Methods

Doubts about methods replace : compute : computeIfAbsent : computeIfPresent : forEach (briefly all that use function or biFuntion within input parameter) Is replace really necessary? this...
asked by 22.08.2014 / 15:21
1
answer

Difference between std :: map, std :: unordered_map, std :: flat_map, and which one to choose?

What is the difference between library functions map , unordered_map , flat_map , and which one to use, for example in terms of performance?     
asked by 23.12.2017 / 02:23
3
answers

Java shows "Type safety: Unchecked cast from Object to HashMap"

I'm creating a class that through which works similar to XPath. The function works perfectly, the problem is that in this part of the line (HashMap<String, Object>) test.get("test-map"); , the "eclipse" shows the following warning...
asked by 30.01.2014 / 17:44
1
answer

Browse HashMapInteger, HashMapInteger, ArrayListInteger

I have the following HashMap : HashMap<Integer,HashMap<Integer,ArrayList<Integer>>> hm = new HashMap<>(); When I do this: Set<Integer> keys = hm.keySet(); for(int i : keys) System.out.println(i + ": " +...
asked by 03.12.2014 / 12:31
1
answer

How to access data from a Hashmap in another class

How can I access data from a Hashmap in another class? Example: Class1: Hashmap<String,String> teste = new Hashmap<>(); teste.put("TESTE", "exemplo"); Class2: How can I get access to Hashmap test? When...
asked by 13.10.2014 / 13:59
1
answer

Map returning repeated values

I am making a foreach in hashmap based on the following arquivo.txt : chaveA;6 chaveA;4 chaveB;3 chaveB;7 chaveC;1 chaveC;1 chaveD;5 For the time being my code looks like this: Scanner scanArquivo = new Scanner(new Fil...
asked by 30.12.2018 / 19:22
1
answer

Exercise with HashMap

I'm trying to do this exercise, I do not know where I'm going wrong. Can you help me? I need to create a map that has the key number of the characters in a city name and a value in a list with all names with that number of characters. You...
asked by 07.12.2017 / 19:25
2
answers

How to use HashMap in this case?

I'm a beginner in Java. I need a program that reads the name and number of some people, and then type a number and the program returns the name of the person associated with the number. I was advised to use HashMap. If anyone has any examples .....
asked by 05.11.2015 / 22:50
1
answer

Problems with hashmap getordefault in java

I have a hashmap problem in JAVA. I'm trying to create a program that reads data from a car, save those cars in an ArrayList, and organize by the manufacturer (that would be the key) the cars of your brand. public static void main(String[]...
asked by 27.09.2017 / 22:17