hello,
i have a question--- i have to implement arraylist by using array.
and i m using following approach-
package DS;
import java.lang.reflect.Array;
public class ArrayList<T> {
T ob[];
public ArrayList(Class<T []> c, int s) {
// Use Array native method to create arra of a type only known at run
// time
ob = c.cast( Array.newInstance(c.getComponentType(), s));
}
@SuppressWarnings("unchecked")
void addItem(T item)
{
for(int i=0;i<ob.length;i++)
{
if(!isFull(i))
{
ob[i]=item;
}
}
@SuppressWarnings("rawtypes")
ArrayList a=new ArrayList(T.class, ob.length);
}
boolean isFull(int i) {
if (ob[i] == null) {
return false;
}
return true;
}
what is prob in the line (red line)...there is no error if i write is for String.