Today I am presenting to you with a Java program which deals with Networking. It demonstrates functioning of java.net.InetAddress class in Java. This Class has many powerful methods which can provide Java developer a powerful API. One of the important method is getLocalHost( ). This method displays the local host address over the console. The User can also print the name of address by calling getByName method. This method takes an parameter of String which is the name of the domain name for which we want the name.
Program to demonstrate working of InetAddress class and the methods of theInetAddress class for Java Networking
package com.hubberspot.networking.example ;
import java.net.* ;
public class InetAddressDemo
public static void main( String [ ] args )
InetAddress address1 = InetAddress.getLocalHost( ) ;