Java method: Finding object in array list given a known attribute value

后端 未结 8 1407
名媛妹妹
名媛妹妹 2020-12-16 11:43

I have a couple of questions actually.

I have a class Dog with the following instance fields:

private int id;
private int id_mother;         


        
8条回答
  •  一向
    一向 (楼主)
    2020-12-16 12:00

    List list = ArrayList();
    
    
    List userNames = list.stream().map(m -> m.getUserName()).collect(Collectors.toList());
    

    output: ["John","Alex"]

提交回复
热议问题