接口不同实例

来源:互联网 发布:otc机器人编程说明书 编辑:程序博客网 时间:2024/05/11 01:59

public class test {

 /**
  * @param args
  * @throws ParseException
  */
 public static void main(String[] args) throws ParseException {
  
  TicketService a  =new OneImple();
  System.out.println(a.getClass().getName());
  System.out.println(TicketService.class.getName());
  TicketService b  =new TowImpl();
  System.out.println(b.getClass().getName());
  System.out.println(TicketService.class.getName());
  
    
        
       
 }
 
  public static TicketService getService(int i)
     {
         TicketService ts=null;
         if(i==1)
         {
             ts = new OneImple();
            
         }
         else
         {
             ts =  new TowImpl();
            
         }
         return ts;
     }

}