public class GenerickeMetody {
public static void main(String[] args) {
Integer[] poleObjCisla = {4, 8, 2, 3};
Character[] poleObjZnaky = {'a', 'x', 'c'};
String[] poleStringov = {"Karol","Eva","Nina"};
vytlacPole(poleObjCisla);
vytlacPole(poleObjZnaky);
vytlacPole(poleStringov);
}
public static <T> void vytlacPole(T[] pole){
for (T t : pole) {
System.out.print(t);
}
System.out.println("");
}
// private static void vytlacPole(Integer[] poleObjCisla) {
// for (Integer i : poleObjCisla) {
// System.out.print(i);
// }
// System.out.println("");
// }
//
// private static void vytlacPole(Character[] poleObjZnaky) {
// for (Character x : poleObjZnaky) {
// System.out.print(x);
// }
// System.out.println("");
// }
}
Comments
0 B
|👍
/👎