Online Java Compiler By
JavaTpoint.com
import java.io.IOException; import java.net.*; public class JavaSocketIsClosedExample2 { public static void main(String[] args) throws IOException { //calling the constructor of the socket class Socket socket = new Socket(); //isClosed() method returns the closing state of the socket //it will return false as the socket is not closed System.out.println("The socket is closed: "+socket.isClosed()); } }
Output