Java if/else behaving strangely

后端 未结 4 721
日久生厌
日久生厌 2021-01-26 18:50

I\'m a real newbie to java, so please excuse me if this is a hopelessly straightforward problem.

I have the following from my java game server:

// Get in         


        
4条回答
  •  醉梦人生
    2021-01-26 19:49

    There are a number of problems with your code

    • in.readLine().trim() readLine do returns null and calling null.trim() will result in ... NullPointerException
    • Is there a reason to append EOF to every response you send.
    • calling substring without making sure it has at least that much elements will throw StringIndexOutOfBoundsException if it is shorter.

    Are you testing with "P" for example?

提交回复
热议问题