Join us on Facebook

Please wait..10 Seconds Cancel

1.03.2014

// // Leave a Comment

Demonstration of All Factory Methods in Java.


Demonstration of all factory methods. 


import java.net.InetAddress; 
import java.net.UnknownHostException; 
 
public class FactoryDemo 
 { 
 
  public static void main(String[] args) 
 { 
     
    try 
 { 
      InetAddress[] i = InetAddress.getAllByName("www.google.com"); 
      InetAddress  i1= InetAddress.getByName("www.google.com"); 
      InetAddress  i2= InetAddress.getLocalHost (); 
       
      for(int ii=0;ii< i.length;ii++) 
        System.out.println("Get All By Name:"+i[ii]); 
 
      System.out.println("Get By Name:"+i1); 
      System.out.println("Get Localhost:"+i2); 
    } 
 catch (UnknownHostException e) 
 { 
      // TODO Auto-generated catch block 
      e.printStackTrace(); 
    } 
  } 
} 

0 comments:

Post a Comment