How do I return an array of objects in java?

后端 未结 7 761
情书的邮戳
情书的邮戳 2021-01-03 05:15

How do I return an array of objects in java?

7条回答
  •  悲&欢浪女
    2021-01-03 06:04

    Answers posted earlier solves your problem perfectly ... so just for sake of another choice .. i will suggest you to use List : may be ArrayList so it could go as :

    public List getListOfObjects() {
       List arrayList = new ArrayList();
       // do some work
       return arrayList;
    }
    
    
    

    Good luck;

    提交回复
    热议问题