3

i tried to store a bytearray in a LinkedHashMap

static Map<Long, byte[]> lhm2 = new LinkedHashMap<Long, byte[]>(1000);

But

lhm2.get(1)

will throw a NullPointerException. lhm2 contains key 1 and i checked if it's not null with

if(lhm2.get(1) != null){
    System.out.println("not null");
}

Any suggestions?

Thanks in advance!

Chris

Chris Jung
  • 49
  • 1
  • 6

2 Answers2

2

your key should be a long so better do this

lhm2.get(1L)

instead of doing like

lhm2.get(1)
Code2Interface
  • 495
  • 2
  • 7
0

You should do:

if(lhm2.contains(1){
    lhm2.get(1)
}
Atropo
  • 12,231
  • 6
  • 49
  • 62