Questions tagged [containskey]

80 questions
-1
votes
2 answers

Calculating nanotime for Java's containsKey operation

I am trying to crate a code, which calculates Java Map's containsKey -operation in nanoseconds (like how fast it runs that operation). Method has a Map D as a parameter, and the value returned should be containsKey operations' normal…
-1
votes
7 answers

HashMap containsKey returns false for Integer

I have this simple code and i figured out that for the last array number the containsKey method returns always false. int[] indices = new int[] { 1, 3, 5, 7, 9 }; Map seen = new HashMap<>(); for (int i = 0; i < indices.length -…
ddarellis
  • 3,912
  • 3
  • 25
  • 53
-1
votes
3 answers

HashMap.containsKey not working for some reason

I wonder why the logic if (!map.containsKey("Africa")) neither go to if block (XX) nor else block (YY) public class HashMapWithListTest { public static void main (String args[]) { HashMap> map=new…
lagunaloire
  • 81
  • 3
  • 9
-3
votes
2 answers

Hashmap contains key return false even when key exists

I have made a hashmap Map percentages= new HashMap();, I have entered values and keys into it and that was successful, but when I try to get the or try ContainsKey method then it returns false. Please see the attached screen shot:
Mr_Hmp
  • 2,474
  • 2
  • 35
  • 53
-3
votes
1 answer

Java cannot find Symbol - containsKey(Item)?

In my Supermarket Checkout Program when I run it, it comes up with this error in the Checkout class in the addItem method: cannot find symbol - method containsKey(Item) I cannot understand why it is coming up with this error as I have checked the…
footballgeek
  • 15
  • 1
  • 5
1 2 3 4 5
6