@@ -0,0 +1,1266 @@
+import java.lang.reflect.Array;%0A%0A%0A/**%0A *%0A * @author Nirmal%0A * @param %3CT%3E Any Class%0A *%0A */%0Apublic class BackPack%3CT%3E %7B%0A%0A    T%5B%5D obj;%0A    int pointer;%0A    int%5B%5D pointerArray;%0A%0A    public BackPack(T%5B%5D obj, int pointer) %7B%0A%0A        pointerArray = new int%5Bobj.length%5D;%0A%0A        for (int i = 0; i %3C obj.length; i++) %7B%0A            pointerArray%5Bi%5D = i;%0A        %7D%0A%0A        this.pointer = pointer;%0A        this.obj = obj;%0A    %7D%0A%0A    public void addContent(T singleObj) %7B%0A    %0A        %0A        obj%5BgetLastElementPointer()%5D = singleObj;%0A        pointer = getLastElementPointer();%0A    %7D%0A%0A    private int getLastElementPointer() %7B%0A%0A        return pointer == 0 ? pointerArray.length - 1 : pointer - 1;%0A    %7D%0A%0A    public T%5B%5D getContent(Class%3CT%3E c) %7B%0A%0A        //initiate new array%0A        T%5B%5D retObj = (T%5B%5D) Array.newInstance(c, pointerArray.length);%0A        int arrayLength = retObj.length;%0A%0A        //index for new array%0A        int j = 0;%0A%0A        int finalPoint = getLastElementPointer();%0A%0A        for (int i = pointer;; i++) %7B%0A%0A            //own iterator%0A            if (i == arrayLength) %7B%0A                i = 0;%0A            %7D%0A%0A            retObj%5Bj++%5D = obj%5Bi%5D;%0A%0A            if (i == finalPoint) %7B%0A                break;%0A            %7D%0A%0A        %7D%0A%0A        return retObj;%0A    %7D%0A%0A%7D%0A

Create new BackPack