What is the output of running class GenericMethodDemo of the
What is the output of running class GenericMethodDemo of the following code?
public class GenericMethodDemo {
public static void main(String[] args ) {
Integer[] integers = {1, 2, 3, 4, 5};
String[] strings = {\"London\", \"Paris\", \"Dhaka\",
\"Austin\", \"Sydney\"};
GenericMethodDemo.<Integer>print(integers);
GenericMethodDemo.<String>print(strings);
}
public static <E> void print(E[] list) {
for (int i = 0; i < list.length; i++){
System.out.print(list[i] + \" \");
}
System.out.println();
}
}
What is the output of running class GenericMethodDemo of the following code?
public class GenericMethodDemo {
public static void main(String[] args ) {
Integer[] integers = {1, 2, 3, 4, 5};
String[] strings = {\"London\", \"Paris\", \"Dhaka\",
\"Austin\", \"Sydney\"};
GenericMethodDemo.<Integer>print(integers);
GenericMethodDemo.<String>print(strings);
}
public static <E> void print(E[] list) {
for (int i = 0; i < list.length; i++){
System.out.print(list[i] + \" \");
}
System.out.println();
}
}
Solution
output 1 :
London
Paris
Dhaka
Austin
Sydney
The above is the output of hte above program
![What is the output of running class GenericMethodDemo of the following code? public class GenericMethodDemo { public static void main(String[] args ) { Integer[ What is the output of running class GenericMethodDemo of the following code? public class GenericMethodDemo { public static void main(String[] args ) { Integer[](/WebImages/11/what-is-the-output-of-running-class-genericmethoddemo-of-the-1005584-1761518365-0.webp)
![What is the output of running class GenericMethodDemo of the following code? public class GenericMethodDemo { public static void main(String[] args ) { Integer[ What is the output of running class GenericMethodDemo of the following code? public class GenericMethodDemo { public static void main(String[] args ) { Integer[](/WebImages/11/what-is-the-output-of-running-class-genericmethoddemo-of-the-1005584-1761518365-1.webp)
