Why we have not used newkeyword in the following program?
import java.net.InetAddress;
public class InetDemo{
public static void main(String[] args){
try{
InetAddress ip=InetAddress.getByName("www.pinterest.com");
System.out.println("Host Name: "+ip.getHostName());
System.out.println("IP Address: "+ip.getHostAddress());
}catch(Exception e){System.out.println(e);}
}
}
Looking at documentation of
InetAddress, we see that this class does not provide public acessible constructors. It uses the factory method pattern instead.