简体   繁体   中英

Cast Object array to custom class array java

I have an Object array that I am trying to cast to custom "document" class. I have tried following:

 this.documentList = Arrays.copyOf(objectDocumentList, objectDocumentList.length,Document[].class);

And

 for(int i=0;i<this.objectDocumentList.length;i++){
     this.documentList[i]= (Document) objectDocumentList[i];
 }

我使用 Gson "toJson" 函数将我的对象转换为字符串,然后使用该字符串通过网络传递。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM