Java 8从其他列表中删除1个列表

Java 8从其他列表中删除1个列表,java,list,collections,java-8,java-stream,Java,List,Collections,Java 8,Java Stream,我有两个不同对象的列表 class School { private String schoolName; private String location; private String pinCode; private String rating; } class World { private String schoolName; private String location; private String country;

我有两个不同对象的列表

class School {
    private String schoolName;
    private String location;
    private String pinCode;
    private String rating;
}

class World {
    private String schoolName;
    private String location;
    private String country;
    private String region;
}

我想根据
学校名称
位置
从世界对象列表中删除学校对象列表。我不能在这两个字段上使用
equals
hashCode
方法,因为这会产生一些其他问题。请帮助我如何使用流来完成它。

您可以使用
过滤器

worldList.stream()
    .filter(world -> schoolList.stream()
        .anyMatch(school -> world.getSchoolName().equals(school.getSchoolName())
                         && world.getLocation().equals(school.getLocation())
    )
    .collect(Collectors.toList());

听起来你的“其他问题”是你的实际问题。你的要求是什么?“基于
学校名称
位置
”这句话实在含糊不清。还有,什么是“其他问题”?