I created a custom class for sockets:
class clientSocket{
Socket clientSocket = null;
public clientSocket() {
}
void accept(ServerSocket welcomeSocket) throws IOException{
clientSocket = welcomeSocket.accept();
}
}
When I try to use it in my server class like below, it throws a null pointer exception:
ServerSocket sSocket = new ServerSocket(1234);
clientSocket[] client = new clientSocket[3];
client[0].accept(sSocket); //this throws a null pointer exception.
Any idea why the 3rd line throws that null pointer?