Java if/else behaving strangely

后端 未结 4 725
日久生厌
日久生厌 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

    1. You need to check for null before you trim it. The result of trim() can never be null.

    2. You should check disconnect first, before the readLine(), otherwise you are always doing one readLine() too many.

    3. If you are never getting to your 'else' it means one of the other conditions is always true.

提交回复
热议问题