DatagramPacket receivePacket = new DatagramPacket(receiveData,
receiveData.length);
_socket.receive(receivePacket);
String sentence = new String(receivePacket.getData());
InetAddress IPAddress = receivePacket.getAddress();
int port = receivePacket.getPort();
if(sentence.equals("hello")) (...)
Question: Why sentence.equal("hello") isn’t true when sentence is "hello"? Is it because of String’s Constructor String(byte[])?
Who can I deal with that?
Thanks
Your string probably contains
"hello"but is padded with other junk. You could tryTo illustrate:
Relevant documentation
trim