学生和课程有两个普通对象,如下所示:
public class Student {
List<Course> courses;
...
}
public class Course {
String name;
...
}
Run Code Online (Sandbox Code Playgroud)
如果我们有一个list的Students,我们怎么能由他们的课程名称进行筛选一些学生的?
flatMap回答这个问题,但它返回课程对象而不是学生对象.allMatch(以下代码).但它会返回学生列表,但List始终为空.问题是什么?List<Student> studentList;
List<Student> AlgorithmsCourserStudentList = studentList.stream().
filter(a -> a.stream().allMatch(c -> c.getCourseName.equal("Algorithms"))).
collect(Collectors.toList());
Run Code Online (Sandbox Code Playgroud) 我想在图中找到所有节点和边缘属性.如何列出图中存在的节点(或边)属性?
例如,如果节点有3个非保留属性,例如NAME,education,gender.我想要一个类似的方法
g.V().schema().toList();
// result: [ID, LABEL, NAME, GENDER, EDUCATION]
Run Code Online (Sandbox Code Playgroud) 是否可以将以下嵌套转换groupingBy为 Kotlin Collections 等效项?
运行此代码: https: //rextester.com/IYJ63609
fun main(args: Array<String>) {
data class Person(val name: String, val city: String, val phone: String)
val people = listOf(
Person("John", "Boston", "+1-888-123456"),
Person("Svyatoslav", "Saint-Petersburg", "+7-999-456700"),
Person("Svyatoslav", "Saint-Petersburg", "+7-999-456789"),
Person("Vasilisa", "Saint-Petersburg", "+7-999-123456"))
val phoneBook = people.stream().collect(
java.util.stream.Collectors.groupingBy(Person::city,
java.util.stream.Collectors.groupingBy(Person::name)
)
)
println(phoneBook)
}
Run Code Online (Sandbox Code Playgroud) collections ×2
java ×2
gremlin ×1
group-by ×1
java-8 ×1
java-stream ×1
kotlin ×1
lambda ×1
tinkerpop3 ×1