    // Print out Internet address information about the local machine.
import java.net.*;

public class PrintInetDetails {
    public static void main(String[] args){
        if(args.length == 0){
            try{
                InetAddress myDetails = InetAddress.getLocalHost();
                System.out.println("The local host is called: "+
                           myDetails.getHostName()+
                           " and its address is: "+
                           myDetails.getHostAddress());
            }
            catch(UnknownHostException e){
                System.err.println("Unknown host: "+e.getMessage());
            }
        }
        else{
            for(int i = 0; i < args.length; i++){
                try{
                    InetAddress details = InetAddress.getByName(args[i]);
                    System.out.println("The host is called: "+
                               details.getHostName()+
                               " and its address is: "+
                               details.getHostAddress());
                }
                catch(UnknownHostException e){
                    System.err.println("Unknown host: "+e.getMessage());
                }
            }
        }
    }
}
