@@ -0,0 +1,1557 @@
+package java_problems.data_structures;%0D%0A%0D%0Aimport java.lang.reflect.Method;%0D%0A%0D%0A/*%0D%0A * Problem Statement: %0D%0A * Generic methods are a very efficient way to handle multiple datatypes using a%0D%0A * single method. This problem will test your knowledge on Java Generic methods.%0D%0A * %0D%0A * Let's say you have an integer array and a string array. You have to write a%0D%0A * single method printArray that can print all the elements of both arrays. The%0D%0A * method should be able to accept both integer arrays or string arrays.%0D%0A * %0D%0A * You are given code in the editor. Complete the code so that it prints the%0D%0A * following lines:%0D%0A * %0D%0A * 1%0D%0A * 2%0D%0A * 3%0D%0A * Hello%0D%0A * World%0D%0A * %0D%0A * Do not use method overloading because your answer will not be accepted.%0D%0A */%0D%0Apublic class JavaGenerics %7B%0D%0A%0D%0A    public static void main( String args%5B%5D )%0D%0A    %7B%0D%0A        Printer myPrinter=new Printer();%0D%0A        Integer%5B%5D intArray = %7B 1, 2, 3 %7D;%0D%0A        String%5B%5D stringArray = %7B%22Hello%22,%22World%22%7D;%0D%0A        myPrinter.printArray( intArray  );%0D%0A        myPrinter.printArray( stringArray );%0D%0A        int count=0;%0D%0A      for (Method method : Printer.class.getDeclaredMethods()) %7B%0D%0A            String name = method.getName();%0D%0A            if(name.equals(%22printArray%22))%0D%0A              count++;%0D%0A        %7D%0D%0A        %0D%0A        if(count%3E1)System.out.println(%22Method overloading is not allowed!%22);%0D%0A        assert count==1;%0D%0A%0D%0A    %7D %0D%0A%7D%0D%0A%0D%0Aclass Printer %7B%0D%0A    %0D%0A    public %3CT%3E void printArray(T%5B%5D array) %7B%0D%0A    %0D%0A        for (T item : array) %7B%0D%0A            System.out.println(item);%0D%0A        %7D%0D%0A    %7D%0D%0A%7D

Add JavaGenerics