package com.main;
import java.util.ArrayList;
import java.util.List;
public class Main {
public static <E> void printArray(E[] inputArray) {
for (E element : inputArray) {
System.out.printf("%s ", element);
}
System.out.println();
}
public static void main(String[] args) {
Integer[] intArray = {1, 2, 3, 4, 5};
Double[] doubleArray = {1.1, 1.2, 1.3};
Character[] charArray = {'A', 'B', 'C'};
printArray(intArray);
printArray(doubleArray);
printArray(charArray);
// 1 2 3 4 5
// 1.1 1.2 1.3
// A B C
Box<Integer> integerBox = new Box<Integer>();
Box<String> stringBox = new Box<String>();
Java泛型使用(一)
最新推荐文章于 2024-03-10 19:43:54 发布