MIT-Curricular/OOP/Java/Lab/Week12/WildCard.java

25 lines
639 B
Java
Raw Permalink Normal View History

2024-10-26 02:14:18 +05:30
class Wildcard {
static void printArray(Object[] elements) {
for (Object element : elements) {
System.out.print(element + " ");
}
System.out.println();
}
public static void main(String[] args) {
Integer[] intArray = { 1, 2, 3, 4, 5 };
String[] stringArray = { "Hello", "World" };
Double[] doubleArray = { 1.1, 2.2, 3.3 };
System.out.println("Integer Array:");
printArray(intArray);
System.out.println("String Array:");
printArray(stringArray);
System.out.println("Double Array:");
printArray(doubleArray);
}
}