Run ❯
Get your
own Java
server
❯
Run Code
Ctrl+Alt+R
Change Orientation
Ctrl+Alt+O
Change Theme
Ctrl+Alt+D
Go to Spaces
Ctrl+Alt+P
public class Main { // Generic method: works with any type T public static
void printArray(T[] array) { for (T item : array) { System.out.println(item); } } public static void main(String[] args) { // Array of Strings String[] names = {"Jenny", "Liam"}; // Array of Integers Integer[] numbers = {1, 2, 3}; // Call the generic method with both arrays printArray(names); printArray(numbers); } }
Jenny
Liam
1
2
3