Array of Sockets Java

前端 未结 4 765
心在旅途
心在旅途 2021-01-15 13:37

I\'m creating server and client java applications. I would like to create an array to store my sockets in. I\'m using eclipse, and when I type in this line:

         


        
4条回答
  •  猫巷女王i
    2021-01-15 14:18

    The resources defined in a try-with-resources block must all be auto-closeable. That's what it's for. Socket[] is not AutoCloseable, so it cannot be defined there. Move the declaration before the try. Ditto for any other resources you get the error on. Don't treat it as a general declaration block. It isn't.

提交回复
热议问题