Java打印对象按类型列出服务

Java打印对象按类型列出服务,java,Java,我有Java打印服务和打印对象列表的方法 public static void print(List<DbMatch> matches){ for(DbMatch m:matches){ System.out.println(m); } } public static void printOdds(List<Odd> odds){ for(Odd o:odds){ System.out.println(o);

我有
Java
打印服务和打印对象列表的方法

public static void print(List<DbMatch> matches){
    for(DbMatch m:matches){
        System.out.println(m);
    }
}

public static void printOdds(List<Odd> odds){
    for(Odd o:odds){
        System.out.println(o);
    }
}
公共静态无效打印(列表匹配){
for(DbMatch m:matches){
系统输出打印项次(m);
}
}
公共静态无效打印赔率(列表赔率){
对于(奇数o:赔率){
系统输出打印ln(o);
}
}
或存在使用一种方法的方式,对于每种类型都不不同,例如:

public static void printObjects(List<Object> objects,Type type){
    for(type o:objects)
        System.out.println(o); 
}


PrintingService.printObjects(odds,"Odd");
PrintingService.printObjects(matches,"DBmatch");
公共静态void打印对象(列表对象,类型){
对于(类型o:对象)
系统输出打印ln(o);
}
PrintingService.printObjects(赔率,“奇数”);
PrintingService.printObjects(匹配,“DBmatch”);

使用这样的通用方法

public static <T> void print(List<T> list){
    for(T m : list){
        System.out.println(m);
    }
}
公共静态作废打印(列表){
对于(T m:列表){
系统输出打印项次(m);
}
}

使用这样的通用方法

public static <T> void print(List<T> list){
    for(T m : list){
        System.out.println(m);
    }
}
公共静态作废打印(列表){
对于(T m:列表){
系统输出打印项次(m);
}
}

和。。。有什么问题吗?还有。。。有什么问题吗?