Added program 8 and screenshot for 8
This commit is contained in:
17
GenericMethodtest.java
Normal file
17
GenericMethodtest.java
Normal file
@@ -0,0 +1,17 @@
|
||||
// 8-A write a java code for generic method
|
||||
public class GenericMethodtest{
|
||||
public static <E> void printArray(E[] inputarray){
|
||||
for(E element: inputarray){
|
||||
System.out.printf("%s", element);
|
||||
}
|
||||
System.out.println();
|
||||
}
|
||||
public static void main(String args[]){
|
||||
Integer[] intarray = {1, 2, 3, 4, 5};
|
||||
Character[] chararray = {'a', 'b','c', 'd'};
|
||||
System.out.println("array in integer");
|
||||
printArray(intarray);
|
||||
System.out.println("array in character");
|
||||
printArray(chararray);
|
||||
}
|
||||
}
|
||||
BIN
Screenshots/program8A.png
Normal file
BIN
Screenshots/program8A.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 9.4 KiB |
Reference in New Issue
Block a user