added program 8B and screenshot for it
This commit is contained in:
17
GenericMethod1.java
Normal file
17
GenericMethod1.java
Normal 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();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user