Java exception must be caught or declared to be thrown [duplicate]
问题 This question already has answers here : Java unreported exception (2 answers) Closed 3 years ago . I am trying to learn Java networking using this manual - http://duta.github.io/writing/StartingNetworking.pdf Why do I get “must be caught or declared to be thrown” at this line (it is ServerSocket part of the manual). Why the code in the manual is assumed to be working, but mine doesn't? Socket socket = serverSocket.accept(); Complete code: public class ChatServer { public static void main(){