Q:

write and execute a java program to find the IP address of your PC

0

write and execute a java program to find the IP address of your PC

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

package com.mycompany.mavenproject2;

import java.net.*;
import java.io.*;
import java.util.*;
import java.net.InetAddress;

public class NewClass {
     public static void main(String args[]) throws Exception
    {
        // Returns the instance of InetAddress containing
        // local host name and address
        InetAddress localhost = InetAddress.getLocalHost();
        System.out.println("My IP Address : " +
                      (localhost.getHostAddress()).trim());
    }
}

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now