Adding elements to an Array. Given the following simple List class that uses an array implementation, write code to add an element at the specified index. Solution //----------------------------------------------------------------- // Adds the specified Comparable element to the list, //----------------------------------------------------------------- public void add (int index,T element) { If(index < 0 || index > rear) throw new IndexOutOfBoundsException(); if (rear == list.length) expandCapacity( ); Comparable<T> temp = (Comparable<T>)element; int scan = 0; while (scan < rear && temp.compareTo(list[scan]) > 0) scan++; for (int scan2=rear; scan2 > scan; scan2--) list[scan2] = list[scan2-1] list[index] = element;//add element in speciefied index rear++; } .