Questions tagged [keyset]

76 questions
2
votes
4 answers

converting hashmap to stringarray

I am trying to convert a hashmap into an array, that I can put in a created string array. I however get java.lang. I have typeconverted my drinkar.keySet().toArray() to String[], but it will still not work. public String[]…
DrWooolie
  • 7,637
  • 7
  • 20
  • 19
1
vote
3 answers

Map.keySet() and Set.addAll throwing NullPoniterException

It is a old code and am debugging it. I have a Map (myMap) with size 2 (for sure). Keys are null and 1. SortedSet mySet = new TreeSet(); mySet.addAll(myMap.keySet()); Iterator mySetIterator = mySet.iterator(); while (mySetIterator.hasNext()) { …
Vaandu
  • 4,857
  • 12
  • 49
  • 75
1
vote
4 answers

Remove a value from a List nested in a Map

I've got a HashMap which contains an ArrayList as value. I want to check if one of the lists contains an object and remove that object from the list. How can I achieve that? I've tried using some for loops, but then I get a…
stijnb1234
  • 184
  • 4
  • 19
1
vote
1 answer

Get HashMap key by inputting HashMap value not working as expected

The problem is in the method getName() public class Phonebook implements PhonebookInterface { private Map> phonebook; private Map address; public Phonebook() { this.phonebook = new…
HorrorRice
  • 33
  • 1
  • 5
1
vote
3 answers

Iterate over an EnumMap which doesn't lead to a new object creation per iteration

Is there a way to iterate over an EnumMap which doesn't lead to a new object creation per iteration? The entryset's iterator returns a new Entry each time. The only way I can see is for(K k: map.keySet()) foo(k, map.get(k)); To clarify this…
hawk
  • 1,827
  • 2
  • 14
  • 28
1
vote
1 answer

Getting incorrect value from Map>

I met a problem when I tried to get values from Map. Here's details. I declared this structure: Map> result4 = new TreeMap<>(); As keys, I used strings like 2_5_1, 3_5_1, 21_4_2 and etc. When I filled result4, I…
0xFF
  • 585
  • 1
  • 6
  • 22
1
vote
2 answers

How can I use map.KeySet() in sql query in java

I have a LinkedHahMap map1 whcih holds key as my beam_current which is of double type and value as my logtime which is of string type. Now I want to use this map1.keySet() in my sql query as- Set arr= map1.keySet(); String vs2="select…
MES
  • 132
  • 1
  • 14
1
vote
1 answer

call keySet() with SharedPreferences.getAll()

I am new to both Java and Android so hopefully my question will make sense (I think I know what I am asking!) I am working my way through an example in a book and I have a query with the following statement: String[] tags =…
Dabur
  • 15
  • 1
  • 4
0
votes
0 answers

Access the map type fields of the static class, and use the keyset() method to obtain its key set, but it is always empty

This is the class I defined, he has a static field PubMsgs. class storage{ private static Map> subLists = new HashMap<>(); private static Map> pubMsgs = new HashMap<>(); private static Lock lock…
0
votes
0 answers

Authorize.net Google Pay Integration, What is the KeySet ID Authorize.net Needs to Create the Signature Key?

Authorize.net documentation leaves much to be desired.. In order to implement Google Pay, which they call Android Pay now, they require that you create a Signature Key.. In order to create the Signature Key they ask that you enter a KeySet ID..…
The MG
  • 21
  • 1
0
votes
2 answers

Convert keys to Values

I'm trying to convert the keys of a Map to Values of another Map, but finally only one key was return as Value. What was the problem? when the program excuted I got different Result import java.util.ArrayList; import…
0
votes
0 answers

Flutter Shortcuts physical key is pressed on a different logical key

I build flutter app for android TV, but I have issue with the IR remote when I press OK key A KeyUpEvent is dispatched, but the state shows that the physical key is pressed on a different logical key. If this occurs in real application, please…
Mahmoud Sabri
  • 713
  • 1
  • 7
  • 22
0
votes
1 answer

Java: HashMap claims it has key, but somehow hasn't

I have a HashMap mapping objects of my Context class to Integers. In the Context class, I did override the public int hashCode() and public boolean equals(Object c) of java.lang.Object. However, I have problems iterating through it: I want (e.g.)…
bufferUnderrun
  • 33
  • 1
  • 1
  • 5
0
votes
5 answers

How to pull random string from a keySet?

I'm working on a problem in which I need to pull a random String from a keySet. Just wondering if anyone can give me some direction here. I'm pretty lost on it. I've found quite a few ways to do it if I were using an int, but not a String. For…
0
votes
2 answers

How to return a Set View of Keys with existing Values?

for example if I have a HashMap with 10 keys, but only 4 keys have a value. How can I return a SetView of these keys. I only found the Map.keySet()-method but this method is giving me EVERY Key in this Hashmap. I only need the ones with value…
Yusuf
  • 1