How to convert object to object[]

前端 未结 4 1705
孤城傲影
孤城傲影 2021-01-17 10:52

I have an object whose value may be one of several array types like int[] or string[], and I want to convert it to a string[]

4条回答
  •  一整个雨季
    2021-01-17 11:44

    The solution below is in JAVA

    public static Objects[] convertObjectToObjectArray(){
        Objects firstObject = new Object();
    
        return new Object[]{firstObject};
    }
    

    In the above return statement, you are converting an object to an object array.

提交回复
热议问题