Array Copy for Any Objects

Hi all,

I wrote a function which is used to concat two Arrays. HOwever, I need to specifiy the data type in the function, it's not OO and absolutely not dynamic, how can I improve it ?

publicstatic Object concatDualArray(Object[] A, Object[] B){

StandingData[] C=new StandingData[A.length+B.length];

System.arraycopy(A, 0, C, 0, A.length);

System.arraycopy(B, 0, C, A.length, B.length);

return C;

}

I summon that function from my core function, which is

StandingData[] trancheStatusListData = (StandingData[])

TrancheUtility.concatDualArray((Object[])trancheApprovedStatusListData, (Object[])trancheApprovalStatusListData);

Is there any reflection method can let my function looks more OO ?

Thanks for helping me

Transistor

[999 byte] By [popohomaa] at [2007-11-26 20:19:20]
# 1

Personally I wouldn't go for the array approach in the first place, because

their type can not be parameterized; e.g. the following is simply not

possible, no matter how cute it looks:public static<T> T[] concatDualArray(T[] A, T[] B) {

T[] C= new T[A.length+B.length];

System.arraycopy(A, 0, C, 0, A.length);

System.arraycopy(B, 0, C, A.length, B.length);

return C;

}

Arrays are very non-OO; why not stick to a List<T> instead?

kind regards,

Jos

JosAHa at 2007-7-10 0:43:13 > top of Java-index,Java Essentials,Java Programming...