Using varargs in a Tag Library Descriptor

后端 未结 4 1630
情话喂你
情话喂你 2021-01-11 17:18

Is it possible to have a TLD map to the following function:

public static  T[] toArray(T... stuff) {
    return stuff;
}

So that I

4条回答
  •  刺人心
    刺人心 (楼主)
    2021-01-11 17:40

    oh well. so this is for literal construction, and there will be limited items

    public static Object[] array(Object x0)
    { return  new Object[] {x0}; }
    
    public static Object[] array(Object x0, Object x1)
    { return  new Object[] {x0, x1}; }
    
    ....
    
    public static Object[] array(Object x0, Object x1, Object x2, ... Object x99)
    { return  new Object[] {x0, x1, x2, ... x99}; }
    

    I don't find it sinful to do this. Auto generate 100 of them and you are set. Ha!

提交回复
热议问题