import java.net.*; public class SocketExample { public static void main(String[] args) { try { Socket socket = new Socket(); socket.setReuseAddress(true); // use the socket... } catch (Exception e) { e.printStackTrace(); } } }In this example, we create a new Socket object and set the reuse address option to true. This allows us to reuse the same address for another socket once the first socket using that address is closed. This method is part of the java.net package library.