You are viewing a single comment's thread. Return to all comments →
public static void main(String[] args) { Object[] arr = {1, 2, 3, "Hello", "World"}; printArray(arr); } static void printArray(T[] array){ for(T element: array){ System.out.println(element); } }
Seems like cookies are disabled on this browser, please enable them to open this website
Java Generics
You are viewing a single comment's thread. Return to all comments →
public static void main(String[] args) { Object[] arr = {1, 2, 3, "Hello", "World"}; printArray(arr); } static void printArray(T[] array){ for(T element: array){ System.out.println(element); } }