added program 8B and screenshot for it

This commit is contained in:
2026-01-29 14:58:22 +05:30
parent 6cb6664760
commit 03ec87b45c
2 changed files with 17 additions and 0 deletions

17
GenericMethod1.java Normal file
View File

@@ -0,0 +1,17 @@
// 8B
public class GenericMethod1{
public static void main(String arg[]){
Integer[] intArray = {1, 2, 3, 4, 5};
String[] stringArray = {"Hello", "World", "!"};
System.out.println("Integer Array: ");
printArray(intArray);
System.out.println("String Array: ");
printArray(stringArray);
}
public static <T> void printArray(T[] arr){
for(T element: arr){
System.out.print(element + " ");
}
System.out.println();
}
}