Using a hashmap value and using getBytes() function - Java UDP

I am getting an nullPointerException on this line sendData = choice.getBytes();. So I think this line String choice = storm.get(enteredLetter); is the problem. The user will enter a letter and it will be used for the keyValue in the hashmap. The program will get the value and let it equal to choice. Any ideas why it giving null pointer?

public static void main(String argv[]) throws Exception {

DatagramSocket serverSocket = new DatagramSocket(9876);

byte[] receiveData = new byte[1024];

byte[] sendData = new byte[1024];

//creating a new hashmap called storm

HashMap storm = new HashMap();


Read More »

By: StackOverFlow - Thursday, 8 November

Related Posts