【问题标题】:Java print the Value List [duplicate]Java打印值列表[重复]
【发布时间】:2020-09-19 11:52:06
【问题描述】:

您好,我正在寻找如何查看我的列表中存在的值的解决方案, 代码:

public Iterable<RfpActiveObject> getactive(){
    List<Rfxobject> rx =     rfx.findAll();
    List<Rfpobject> rp = rfp.findAll();

    Long compteurRfx =rfp.count();
    Long CompteurRfp= rfx.count();
    long TabMax = compteurRfx+CompteurRfp;
    List<Object> newList = new ArrayList<Object>();
    newList.add(rx);
    newList.add(rp);
    for(int i =0 ; i<  TabMax ; i++) {
        RfpActiveObject rf =  new RfpActiveObject();
        System.out.println("**** Liste "+i+"  :");
        System.out.println(newList.get(0));
        System.out.println("**** *****************");
     }
}

我的列表的输入是:

**** Liste 13  :
[com.pfe.backend.models.Rfxobject@2767bc, com.pfe.backend.models.Rfxobject@2389804e, com.pfe.backend.models.Rfxobject@31eda7ed, com.pfe.backend.models.Rfxobject@5ba91ebd, com.pfe.backend.models.Rfxobject@600898f3, com.pfe.backend.models.Rfxobject@fecef4c]
**** *****************

我需要得到真正的价值而不是解决我应该做什么

【问题讨论】:

    标签: java list hibernate object arraylist


    【解决方案1】:

    您必须覆盖两个类中的 toString() 方法 - Rfxobject 和 Rfpobject。

    More details

    【讨论】:

    • @GetMapping("/active") public Iterable getactive(){ List rx = rfx.findAll();列表 rp = rfp.findAll();长 compteurRfx =rfp.count();长 CompteurRfp=rfx.count();长 TabMax = compteurRfx+CompteurRfp;列表 newList = new ArrayList(); newList.add(rx);新列表.add(rp);迭代器 ii = newList.iterator(); while (ii.hasNext()) { System.out.println(ii.next());}return null;}
    • 但是我已经有了相同的输入,请问我应该怎么做
    • @Override public String toString() { return getClass().getName() + "@" + Integer.toHexString(hashCode()); }
    猜你喜欢
    • 1970-01-01
    • 2017-10-12
    • 2012-06-05
    • 2021-04-09
    • 1970-01-01
    • 2017-04-12
    • 2018-02-13
    • 2019-12-02
    • 2021-07-21
    相关资源
    最近更新 更多