Factory Method Example -2 in Java

 /*  
 Factory Method Example using java API  
 author: itsafiz@gmail.com  
 */  
 import java.util.*;   
 import java.text.*;   
 class FactoryMethodExample // main class   
 {  
      public static void main(String[]args)  
      {  
      NumberFormat currencyFormatter = NumberFormat.getCurrencyInstance();   
      NumberFormat percentFormatter = NumberFormat.getPercentInstance();  
      double a = 20.5;   
      System.out.println(currencyFormatter.format(a));  
      System.out.println(percentFormatter.format(a));  
      }  
 }  

Post a Comment

0 Comments