when i tried to compile the following program, i got an incompatible type error ... (for returning an array) ....
import java.lang.reflect.Array;
class ResizeArray
{
static int z;
public int resizeArr(int [] b,int n)
{
z = n;
b = new int[10];
b = (int[])ArrayUtils.expand(b);
return b;
}
public static Object expand(Object a)
{
Class cl = a.getClass();
if (!cl.isArray()) return null;
int length = Array.getLength(a);
int newLength = z;
Class componentType = a.getClass().getComponentType();
Object newArray = Array.newInstance(componentType, newLength);
System.arraycopy(a, 0, newArray, 0, length);
return newArray;
}
public static void main(
String args[])
{
ResizeArray ra = new ResizeArray();
int a[] = {1,2,3,4,5};
System.out.println("main length "+a.length);
int d=3;
ra.resizeArr(a,d);
}
}
watz the error in it ???