Question: Java: Briefly explain the code in each area with /*comment*/ above it import java.net.*; import java.io.*; public class MessageClient { public static final int PORT
Java: Briefly explain the code in each area with /*comment*/ above it
import java.net.*; import java.io.*;
public class MessageClient { public static final int PORT = 6100; public static final String host = "127.0.0.1";
public static void main(String[] args) throws IOException { Socket sock = null; if (args.length != 1) { System.err.println("Usage: java MessageClient
PrintWriter pout = new PrintWriter(sock.getOutputStream(),true);
pout.println(args[0]);
/* Comment Here */ ObjectInputStream ois = new ObjectInputStream(sock.getInputStream());
Message message = (Message) ois.readObject(); System.out.println(message.getCharacterCount()); System.out.println(message.getDigitCount()); } catch (IOException ioe) { System.err.println(ioe); } catch (ClassNotFoundException cnfe) { System.err.println(cnfe); } finally { sock.close(); } } }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
