added till 8th b and c
This commit is contained in:
20
GenericMethod1.java
Normal file
20
GenericMethod1.java
Normal file
@@ -0,0 +1,20 @@
|
||||
public class GenericMethod1
|
||||
{
|
||||
public static void main(String[] args)
|
||||
{
|
||||
Integer[] intArray = {1, 2 , 3 ,4 ,5};
|
||||
String[] stringArray = {"Hello", "Adi", "!"};
|
||||
System.out.print("Integer Array:");
|
||||
printArray(intArray);
|
||||
System.out.print("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