在示例代码中,用方法引用替代语句Comparator[User] comparator = Comparator.comparing(u -> u.getUserName())正确的是()。
A: Comparator comparator = Comparator.comparing(uses::getUserName)
B: Comparator comparator = Comparator.comparing(User::getUserName)
C: Comparator< > comparator = Comparator.comparing(uses::getUserName)
D: Comparator< > comparator = Comparator.comparing(User::getUserName)
A: Comparator
B: Comparator
C: Comparator< > comparator = Comparator.comparing(uses::getUserName)
D: Comparator< > comparator = Comparator.comparing(User::getUserName)