成人国产在线小视频_日韩寡妇人妻调教在线播放_色成人www永久在线观看_2018国产精品久久_亚洲欧美高清在线30p_亚洲少妇综合一区_黄色在线播放国产_亚洲另类技巧小说校园_国产主播xx日韩_a级毛片在线免费

資訊專欄INFORMATION COLUMN

Stream流與Lambda表達(dá)式(三) 靜態(tài)工廠類Collectors

phodal / 3614人閱讀

摘要:陳楊一靜態(tài)工廠類實(shí)現(xiàn)方式一靜態(tài)工廠類實(shí)現(xiàn)方式靜態(tài)工廠類最終由實(shí)現(xiàn)通過(guò)實(shí)現(xiàn)通過(guò)實(shí)現(xiàn)底層由實(shí)現(xiàn)是的一種具化表現(xiàn)形式使用拼接字符串二靜態(tài)工廠類常用收集器二靜態(tài)工廠類常用收集器返回一個(gè)不可修改的按照相遇的順序返回一個(gè)不可修改的無(wú)序返回

/**
 * @author 陳楊
 */

@SpringBootTest
@RunWith(SpringRunner.class)
public class CollectorsDetail {

    private List names;
    private List students;
    private List> snames;

    @Before
    public void init() {

        names = Arrays.asList("Kirito", "Asuna", "Sinon", "Yuuki", "Alice");
        snames = Arrays.asList(Collections.singletonList("Kirito"), Collections.singletonList("Asuna"),
                Collections.singletonList("Sinon"), Collections.singletonList("Yuuki"),
                Collections.singletonList("Alice"));

        students = new Students().init();
    }

    @Test
    public void testCollectorsDetail() {
一、靜態(tài)工廠類Collectors 實(shí)現(xiàn)方式
//    一、靜態(tài)工廠類Collectors 實(shí)現(xiàn)方式

//    Collectors 靜態(tài)工廠類   最終由CollectorImpl實(shí)現(xiàn)
//       1、 通過(guò)CollectorImpl實(shí)現(xiàn)
//       2、 通過(guò)reducing()實(shí)現(xiàn)---> reducing()底層由CollectorImpl實(shí)現(xiàn)


//    Collectors.toList()  是 Collectors.toCollection()的一種具化表現(xiàn)形式
//    Collectors.joining() 使用StringBuilder.append 拼接字符串
二、靜態(tài)工廠類Collectors 常用收集器
//    二、靜態(tài)工廠類Collectors 常用收集器

/*
      返回一個(gè)(不可修改)unmodifiable List的ArrayList  按照相遇的順序encounter order
@since 10
@SuppressWarnings("unchecked")
public static 
        Collector> toUnmodifiableList() {
    return new CollectorImpl<>((Supplier>) ArrayList::new, List::add,
            (left, right) -> { left.addAll(right); return left; },
            list -> (List)List.of(list.toArray()),
            CH_NOID);
}*/


/*
      返回一個(gè)(不可修改)unmodifiable Set的HashSet 無(wú)序
@since 10
@SuppressWarnings("unchecked")
public static 
        Collector> toUnmodifiableSet() {
    return new CollectorImpl<>((Supplier>) HashSet::new, Set::add,
            (left, right) -> {
                if (left.size() < right.size()) {
                    right.addAll(left); return right;
                } else {
                    left.addAll(right); return left;
                }
            },
            set -> (Set)Set.of(set.toArray()),
            CH_UNORDERED_NOID);
}
*/


/*
      返回一個(gè)flatMapping扁平化mapper處理后 由downstream收集的 累加器處理的結(jié)果合并  單線程
@since 9
public static 
        Collector flatMapping(Function> mapper,
        Collector downstream) {
    BiConsumer downstreamAccumulator = downstream.accumulator();
    return new CollectorImpl<>(downstream.supplier(),
            (r, t) -> {
                try (Stream result = mapper.apply(t)) {
                    if (result != null)
                        result.sequential().forEach(u -> downstreamAccumulator.accept(r, u));
                }
            },
            downstream.combiner(), downstream.finisher(),
            downstream.characteristics());
}*/



/*
      對(duì)符合Predicate預(yù)期結(jié)果 進(jìn)行過(guò)濾filtering 使用downstream 收集元素
@since 9
public static 
        Collector filtering(Predicate predicate,
        Collector downstream) {
    BiConsumer downstreamAccumulator = downstream.accumulator();
    return new CollectorImpl<>(downstream.supplier(),
            (r, t) -> {
                if (predicate.test(t)) {
                    downstreamAccumulator.accept(r, t);
                }
            },
            downstream.combiner(), downstream.finisher(),
            downstream.characteristics());
}*/


/*
      使用Map映射key-->keyMapper-->Key value-->valueMapper-->Value
      對(duì)映射后的結(jié)果進(jìn)行組裝entrySet-->Map (unmodifiable Map)
@since 10
@SuppressWarnings({"rawtypes", "unchecked"})
public static 
        Collector> toUnmodifiableMap(Function keyMapper,
        Function valueMapper) {
    Objects.requireNonNull(keyMapper, "keyMapper");
    Objects.requireNonNull(valueMapper, "valueMapper");
    return collectingAndThen(
            toMap(keyMapper, valueMapper),
            map -> (Map)Map.ofEntries(map.entrySet().toArray(new Map.Entry[0])));
}*/


/*
      使用Map映射key-->keyMapper-->Key value-->valueMapper-->Value
      mergeFunction 對(duì)相同key 映射后的進(jìn)行Value 合并操作
      對(duì)映射后的結(jié)果進(jìn)行組裝entrySet-->Map (unmodifiable Map)

@since 10
@SuppressWarnings({"rawtypes", "unchecked"})
public static 
        Collector> toUnmodifiableMap(Function keyMapper,
        Function valueMapper,
        BinaryOperator mergeFunction) {
    Objects.requireNonNull(keyMapper, "keyMapper");
    Objects.requireNonNull(valueMapper, "valueMapper");
    Objects.requireNonNull(mergeFunction, "mergeFunction");
    return collectingAndThen(
            toMap(keyMapper, valueMapper, mergeFunction, HashMap::new),
            map -> (Map)Map.ofEntries(map.entrySet().toArray(new Map.Entry[0])));
}*/
//    Collectors 收集器
System.out.println("-----------------------------------------
");

//    使用ArrayList集合 按照流中元素排列先后順序 進(jìn)行添加操作
List unmodifiableList = names.stream().collect(Collectors.toUnmodifiableList());
System.out.println(unmodifiableList);
System.out.println("---------------------------------------
");


//    使用HashSet集合 對(duì)流中元素順序 進(jìn)行添加操作
Set unmodifiableSet = names.stream().collect(Collectors.toUnmodifiableSet());
System.out.println(unmodifiableSet);
System.out.println("---------------------------------------
");


//    將集合扁平化展開(kāi) 對(duì)其中的字符串的每個(gè)字母 進(jìn)行大寫轉(zhuǎn)換 使用ArrayList對(duì)轉(zhuǎn)換后的結(jié)果進(jìn)行收集
List strings = snames.stream()
        .collect(Collectors.flatMapping(list -> list.stream().map(String::toUpperCase), Collectors.toList()));
System.out.println(strings);
System.out.println("---------------------------------------
");


//    對(duì)流中元素進(jìn)行遍歷 對(duì)符合預(yù)期要求的元素 使用ArrayList集合存放
List filteringPredicate = names.stream().collect(Collectors.filtering("Kirito"::equals,
        Collectors.toList()));
System.out.println(filteringPredicate);
System.out.println("---------------------------------------
");


//    對(duì)流中元素進(jìn)行遍歷  對(duì)key-->keyMapper value-->valueMapper 映射 得到Map集合
Map> listMap = students.stream()
        .collect(Collectors.toUnmodifiableMap(Student::getId, student -> {
            List stus = new ArrayList<>();
            stus.add(student);
            return stus;
        }));

System.out.println(listMap);
System.out.println("---------------------------------------
");


//    對(duì)流中元素進(jìn)行遍歷 對(duì)key-->keyMapper-->Key value-->valueMapper-->Value 映射
//    對(duì)滿足相同Key的元素 Value進(jìn)行合并
Map lengthName = names.stream()
        .collect(Collectors.toUnmodifiableMap(String::length,
                String::toString, (str1, str2) -> str1 + "	" + str2));
System.out.println(lengthName);
System.out.println("---------------------------------------
");
三、groupingBy分組
//    三、groupingBy分組

//    分組 groupingBy

//    對(duì)T元素按 key進(jìn)行分組 --> 分組的依據(jù) classifier--> 分組后的集合 value--> 得到 Map
/*
Returns a {@code Collector} implementing a "group by" operation on
input elements of type {@code T}, grouping elements according to a
         classification function, and returning the results in a {@code Map}.

The classification function maps elements to some key type {@code K}. The collector produces a {@code Map>} whose keys are the values resulting from applying the classification function to the input elements, and whose corresponding values are {@code List}s containing the input elements which map to the associated key under the classification function.

There are no guarantees on the type, mutability, serializability, or thread-safety of the {@code Map} or {@code List} objects returned.*/ /* 按照key對(duì)T進(jìn)行classifier分組 使用List集合收集分組結(jié)果 單線程 線程安全 public static Collector>> groupingBy(Function classifier) { return groupingBy(classifier, toList()); }*/ /* 按照key對(duì)T進(jìn)行classifier分組 使用自定義收集器downstream 收集分組結(jié)果 單線程 線程安全 public static Collector> groupingBy(Function classifier, Collector downstream) { return groupingBy(classifier, HashMap::new, downstream); }*/ /* 按照key對(duì)T進(jìn)行classifier分組 使用自定義mapFactory 重置downstream的CollectorImpl實(shí)現(xiàn) 使用自定義收集器downstream 收集分組結(jié)果 單線程 線程安全 public static > Collector groupingBy(Function classifier, Supplier mapFactory, Collector downstream) { Supplier downstreamSupplier = downstream.supplier(); BiConsumer downstreamAccumulator = downstream.accumulator(); BiConsumer, T> accumulator = (m, t) -> { K key = Objects.requireNonNull(classifier.apply(t), "element cannot be mapped to a null key"); A container = m.computeIfAbsent(key, k -> downstreamSupplier.get()); downstreamAccumulator.accept(container, t); }; BinaryOperator> merger = Collectors.>mapMerger(downstream.combiner()); @SuppressWarnings("unchecked") Supplier> mangledFactory = (Supplier>) mapFactory; // 不進(jìn)行強(qiáng)制類型轉(zhuǎn)換 重構(gòu)CollectorImpl實(shí)現(xiàn) if (downstream.characteristics().contains(Collector.Characteristics.IDENTITY_FINISH)) { return new CollectorImpl<>(mangledFactory, accumulator, merger, CH_ID); } else { // 進(jìn)行強(qiáng)制類型轉(zhuǎn)換 重構(gòu)CollectorImpl實(shí)現(xiàn) @SuppressWarnings("unchecked") Function downstreamFinisher = (Function) downstream.finisher(); Function, M> finisher = intermediate -> { intermediate.replaceAll((k, v) -> downstreamFinisher.apply(v)); @SuppressWarnings("unchecked") M castResult = (M) intermediate; return castResult; }; return new CollectorImpl<>(mangledFactory, accumulator, merger, finisher, CH_NOID); } }*/

//    分組
System.out.println("-----------------------------------------
");


//    select * from students group by sex ;
Map> sexStudent =
        students.stream().collect(Collectors.groupingBy(Student::getSex));
System.out.println(sexStudent);
System.out.println("-----------------------------------------
");


//    select sex, count(*) from students group by sex ;
Map sexCount =
        students.stream().collect(Collectors.groupingBy(Student::getSex, Collectors.counting()));
System.out.println(sexCount);
System.out.println("-----------------------------------------
");


//    select sex,avg(salary) from students group by sex ;
Map avgSexSalary = students.stream().collect
        (Collectors.groupingBy(Student::getSex, Collectors.averagingDouble(Student::getSalary)));
System.out.println(avgSexSalary);
System.out.println("-----------------------------------------
");


//    嵌套分組  先根據(jù)sex分組 再對(duì)結(jié)果按照addr進(jìn)行分組
Map>> NestedGroupBy = students.stream()
        .collect(Collectors.groupingBy(Student::getSex, Collectors.groupingBy(Student::getAddr)));
System.out.println(NestedGroupBy);
System.out.println("-----------------------------------------
");


//    使用自定義收集器downstream 按性別分組  使用HashSet進(jìn)行 結(jié)果收集
Map> sexHashSet = students.stream()
        .collect(Collectors.groupingBy(Student::getSex, Collectors.toCollection(HashSet::new)));
System.out.println(sexHashSet);
System.out.println("-----------------------------------------
");


//    使用自定義收集器downstream 按性別分組  使用HashSet進(jìn)行 結(jié)果收集  重置CollectorImpl實(shí)現(xiàn)
Map> sexCustomCollectorImpl = students.stream()
        .collect(Collectors.groupingBy(Student::getSex, Hashtable::new, Collectors.toCollection(HashSet::new)));
System.out.println(sexCustomCollectorImpl);
System.out.println("-----------------------------------------
");
四、groupingByConcurrent分組
 //    四、groupingByConcurrent分組

 //    分組 groupingByConcurrent

 //    流的適用條件:
 //          無(wú)序 Collector.Characteristics.UNORDERED
 //          并發(fā) Collector.Characteristics.CONCURRENT
 //    This is a {@link Collector.Characteristics#CONCURRENT concurrent} and
 //    {@link Collector.Characteristics#UNORDERED unordered} Collector.


 /*
       按照key對(duì)T進(jìn)行classifier分組
       使用List集合收集分組結(jié)果
 public static 
         Collector>>
 groupingByConcurrent(Function classifier) {
     return groupingByConcurrent(classifier,  ::new, toList());
 }*/


/*
       按照key對(duì)T進(jìn)行classifier分組
       使用自定義收集器downstream 收集分組結(jié)果
public static 
         Collector> groupingByConcurrent(Function classifier,
         Collector downstream) {
     return groupingByConcurrent(classifier, ConcurrentHashMap::new, downstream);
 }*/


 /*
       按照key對(duì)T進(jìn)行classifier分組
       使用自定義累加器mapFactory  重置downstream的CollectorImpl實(shí)現(xiàn)
       使用自定義收集器downstream 收集分組結(jié)果
 public static >
 Collector groupingByConcurrent(Function classifier,
         Supplier mapFactory,
         Collector downstream) {
     Supplier downstreamSupplier = downstream.supplier();
     BiConsumer downstreamAccumulator = downstream.accumulator();
     BinaryOperator> merger = Collectors.>mapMerger(downstream.combiner());
     @SuppressWarnings("unchecked")
     Supplier> mangledFactory = (Supplier>) mapFactory;
     BiConsumer, T> accumulator;
     if (downstream.characteristics().contains(Collector.Characteristics.CONCURRENT)) {
         accumulator = (m, t) -> {
             K key = Objects.requireNonNull(classifier.apply(t), "element cannot be mapped to a null key");
             A resultContainer = m.computeIfAbsent(key, k -> downstreamSupplier.get());
             downstreamAccumulator.accept(resultContainer, t);
         };
     }
     else {
         accumulator = (m, t) -> {
             K key = Objects.requireNonNull(classifier.apply(t), "element cannot be mapped to a null key");
             A resultContainer = m.computeIfAbsent(key, k -> downstreamSupplier.get());
             //  多個(gè)操作-->同時(shí)操作同一個(gè)結(jié)果容器-->同一時(shí)間,有且只有一個(gè)進(jìn)行實(shí)際操作-->線程同步
             synchronized (resultContainer) {
                 downstreamAccumulator.accept(resultContainer, t);
             }
         };
     }

     if (downstream.characteristics().contains(Collector.Characteristics.IDENTITY_FINISH)) {
         return new CollectorImpl<>(mangledFactory, accumulator, merger, CH_CONCURRENT_ID);
     }
     else {
         @SuppressWarnings("unchecked")
         Function downstreamFinisher = (Function) downstream.finisher();
         Function, M> finisher = intermediate -> {
             intermediate.replaceAll((k, v) -> downstreamFinisher.apply(v));
             @SuppressWarnings("unchecked")
             M castResult = (M) intermediate;
             return castResult;
         };
         return new CollectorImpl<>(mangledFactory, accumulator, merger, finisher, CH_CONCURRENT_NOID);
     }
 }*/
//    分組 無(wú)序 并發(fā)
System.out.println("-----------------------------------------
");

//    按性別分組  使用ArrayList進(jìn)行 結(jié)果收集
ConcurrentMap> sexStudentConcurrent = students.stream()
        .collect(Collectors.groupingByConcurrent(Student::getSex));
System.out.println(sexStudentConcurrent);
System.out.println("-----------------------------------------
");


//    使用自定義收集器downstream 按性別分組  使用HashSet進(jìn)行 結(jié)果收集
ConcurrentMap> sexHashSetConcurrent = students.stream()
        .collect(Collectors.groupingByConcurrent(Student::getSex, Collectors.toCollection(HashSet::new)));
System.out.println(sexHashSetConcurrent);
System.out.println("-----------------------------------------
");


//    使用自定義收集器downstream 按性別分組  使用HashSet進(jìn)行 結(jié)果收集  重置CollectorImpl實(shí)現(xiàn)
ConcurrentReferenceHashMap> sexCustomCollectorImplConcurrent =
        students.stream().collect(Collectors.groupingByConcurrent(Student::getSex,
                ConcurrentReferenceHashMap::new, Collectors.toCollection(HashSet::new)));
System.out.println(sexCustomCollectorImplConcurrent);
System.out.println("-----------------------------------------
");
五、partitioningBy分區(qū)
//    五、partitioningBy分區(qū)

//  分區(qū)  partitioningBy

/*
      對(duì)滿足預(yù)期的條件 進(jìn)行分區(qū) 使用ArrayList 進(jìn)行結(jié)果的收集
public static 
        Collector>> partitioningBy(Predicate predicate) {
    return partitioningBy(predicate, toList());
}*/


/*
      對(duì)滿足預(yù)期的條件 進(jìn)行分區(qū) 使用自定義收集器downstream 進(jìn)行結(jié)果的收集
public static 
        Collector> partitioningBy(Predicate predicate,
        Collector downstream) {
    BiConsumer downstreamAccumulator = downstream.accumulator();
    BiConsumer, T> accumulator = (result, t) ->
            downstreamAccumulator.accept(predicate.test(t) ? result.forTrue : result.forFalse, t);
    BinaryOperator op = downstream.combiner();
    BinaryOperator> merger = (left, right) ->
            new Partition<>(op.apply(left.forTrue, right.forTrue),
                    op.apply(left.forFalse, right.forFalse));
    Supplier> supplier = () ->
            new Partition<>(downstream.supplier().get(),
                    downstream.supplier().get());
    if (downstream.characteristics().contains(Collector.Characteristics.IDENTITY_FINISH)) {
        return new CollectorImpl<>(supplier, accumulator, merger, CH_ID);
    }
    else {
        Function, Map> finisher = par ->
                new Partition<>(downstream.finisher().apply(par.forTrue),
                        downstream.finisher().apply(par.forFalse));
        return new CollectorImpl<>(supplier, accumulator, merger, finisher, CH_NOID);
    }
}*/
        //    分區(qū)
        System.out.println("-----------------------------------------
");

        //    select * from students partition by (addr == Sword Art Online) ;
        Map> addrPartition = students.stream().collect
                (Collectors.partitioningBy(student -> student.getAddr().equals("Sword Art Online")));
        System.out.println(addrPartition);
        System.out.println("-----------------------------------------
");


        //    嵌套分區(qū)  先根據(jù)sex分區(qū) 再對(duì)結(jié)果按照addr進(jìn)行分區(qū)
        Map>> NestedPartiton = students.stream()
                .collect(Collectors.partitioningBy(student -> student.getSex().equals("Male"),
                        Collectors.partitioningBy(student -> student.getAddr().equals("Sword Art Online"))));
        System.out.println(NestedPartiton);
        System.out.println("-----------------------------------------
");


        //    使用自定義downstream收集器分區(qū)
        Map> addrCustomPartition = students.stream().collect(Collectors.partitioningBy
                (student -> student.getAddr().equals("Sword Art Online"), Collectors.toCollection(HashSet::new)));
        System.out.println(addrCustomPartition);
        System.out.println("-----------------------------------------
");

    }

}
六、測(cè)試結(jié)果
  .   ____          _            __ _ _
 / / ___"_ __ _ _(_)_ __  __ _    
( ( )\___ | "_ | "_| | "_ / _` |    
 /  ___)| |_)| | | | | || (_| |  ) ) ) )
  "  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::        (v2.1.2.RELEASE)

2019-02-20 16:58:15.870  INFO 13392 --- [           main] c.j.d.java8.Stream.CollectorsDetail      : Starting CollectorsDetail on DESKTOP-87RMBG4 with PID 13392 (started by 46250 in E:IdeaProjectsdesign)
2019-02-20 16:58:15.871  INFO 13392 --- [           main] c.j.d.java8.Stream.CollectorsDetail      : No active profile set, falling back to default profiles: default
2019-02-20 16:58:16.383  INFO 13392 --- [           main] c.j.d.java8.Stream.CollectorsDetail      : Started CollectorsDetail in 0.708 seconds (JVM running for 1.421)
-----------------------------------------

[Kirito, Asuna, Sinon, Yuuki, Alice]
---------------------------------------

[Yuuki, Asuna, Kirito, Sinon, Alice]
---------------------------------------

[KIRITO, ASUNA, SINON, YUUKI, ALICE]
---------------------------------------

[Kirito]
---------------------------------------

{5=[Student(id=5, name=Alice, sex=Female, age=14, addr=Alicization, salary=9.99999999E8)], 4=[Student(id=4, name=Yuuki, sex=Female, age=15, addr=Alfheim Online, salary=9.99999999E8)], 3=[Student(id=3, name=Sinon, sex=Female, age=16, addr=Gun Gale Online, salary=9.99999999E8)], 2=[Student(id=2, name=Asuna, sex=Female, age=17, addr=Sword Art Online, salary=9.99999999E8)], 1=[Student(id=1, name=Kirito, sex=Male, age=18, addr=Sword Art Online, salary=9.99999999E8)]}
---------------------------------------

{6=Kirito, 5=Asuna    Sinon    Yuuki    Alice}
---------------------------------------

-----------------------------------------

{Female=[Student(id=2, name=Asuna, sex=Female, age=17, addr=Sword Art Online, salary=9.99999999E8), Student(id=3, name=Sinon, sex=Female, age=16, addr=Gun Gale Online, salary=9.99999999E8), Student(id=4, name=Yuuki, sex=Female, age=15, addr=Alfheim Online, salary=9.99999999E8), Student(id=5, name=Alice, sex=Female, age=14, addr=Alicization, salary=9.99999999E8)], Male=[Student(id=1, name=Kirito, sex=Male, age=18, addr=Sword Art Online, salary=9.99999999E8)]}
-----------------------------------------

{Female=4, Male=1}
-----------------------------------------

{Female=9.99999999E8, Male=9.99999999E8}
-----------------------------------------

{Female={Alicization=[Student(id=5, name=Alice, sex=Female, age=14, addr=Alicization, salary=9.99999999E8)], Sword Art Online=[Student(id=2, name=Asuna, sex=Female, age=17, addr=Sword Art Online, salary=9.99999999E8)], Gun Gale Online=[Student(id=3, name=Sinon, sex=Female, age=16, addr=Gun Gale Online, salary=9.99999999E8)], Alfheim Online=[Student(id=4, name=Yuuki, sex=Female, age=15, addr=Alfheim Online, salary=9.99999999E8)]}, Male={Sword Art Online=[Student(id=1, name=Kirito, sex=Male, age=18, addr=Sword Art Online, salary=9.99999999E8)]}}
-----------------------------------------

{Female=[Student(id=4, name=Yuuki, sex=Female, age=15, addr=Alfheim Online, salary=9.99999999E8), Student(id=3, name=Sinon, sex=Female, age=16, addr=Gun Gale Online, salary=9.99999999E8), Student(id=5, name=Alice, sex=Female, age=14, addr=Alicization, salary=9.99999999E8), Student(id=2, name=Asuna, sex=Female, age=17, addr=Sword Art Online, salary=9.99999999E8)], Male=[Student(id=1, name=Kirito, sex=Male, age=18, addr=Sword Art Online, salary=9.99999999E8)]}
-----------------------------------------

{Female=[Student(id=4, name=Yuuki, sex=Female, age=15, addr=Alfheim Online, salary=9.99999999E8), Student(id=3, name=Sinon, sex=Female, age=16, addr=Gun Gale Online, salary=9.99999999E8), Student(id=5, name=Alice, sex=Female, age=14, addr=Alicization, salary=9.99999999E8), Student(id=2, name=Asuna, sex=Female, age=17, addr=Sword Art Online, salary=9.99999999E8)], Male=[Student(id=1, name=Kirito, sex=Male, age=18, addr=Sword Art Online, salary=9.99999999E8)]}
-----------------------------------------

-----------------------------------------

{Male=[Student(id=1, name=Kirito, sex=Male, age=18, addr=Sword Art Online, salary=9.99999999E8)], Female=[Student(id=2, name=Asuna, sex=Female, age=17, addr=Sword Art Online, salary=9.99999999E8), Student(id=3, name=Sinon, sex=Female, age=16, addr=Gun Gale Online, salary=9.99999999E8), Student(id=4, name=Yuuki, sex=Female, age=15, addr=Alfheim Online, salary=9.99999999E8), Student(id=5, name=Alice, sex=Female, age=14, addr=Alicization, salary=9.99999999E8)]}
-----------------------------------------

{Male=[Student(id=1, name=Kirito, sex=Male, age=18, addr=Sword Art Online, salary=9.99999999E8)], Female=[Student(id=4, name=Yuuki, sex=Female, age=15, addr=Alfheim Online, salary=9.99999999E8), Student(id=3, name=Sinon, sex=Female, age=16, addr=Gun Gale Online, salary=9.99999999E8), Student(id=5, name=Alice, sex=Female, age=14, addr=Alicization, salary=9.99999999E8), Student(id=2, name=Asuna, sex=Female, age=17, addr=Sword Art Online, salary=9.99999999E8)]}
-----------------------------------------

{Female=[Student(id=4, name=Yuuki, sex=Female, age=15, addr=Alfheim Online, salary=9.99999999E8), Student(id=3, name=Sinon, sex=Female, age=16, addr=Gun Gale Online, salary=9.99999999E8), Student(id=5, name=Alice, sex=Female, age=14, addr=Alicization, salary=9.99999999E8), Student(id=2, name=Asuna, sex=Female, age=17, addr=Sword Art Online, salary=9.99999999E8)], Male=[Student(id=1, name=Kirito, sex=Male, age=18, addr=Sword Art Online, salary=9.99999999E8)]}
-----------------------------------------

-----------------------------------------

{false=[Student(id=3, name=Sinon, sex=Female, age=16, addr=Gun Gale Online, salary=9.99999999E8), Student(id=4, name=Yuuki, sex=Female, age=15, addr=Alfheim Online, salary=9.99999999E8), Student(id=5, name=Alice, sex=Female, age=14, addr=Alicization, salary=9.99999999E8)], true=[Student(id=1, name=Kirito, sex=Male, age=18, addr=Sword Art Online, salary=9.99999999E8), Student(id=2, name=Asuna, sex=Female, age=17, addr=Sword Art Online, salary=9.99999999E8)]}
-----------------------------------------

{false={false=[Student(id=3, name=Sinon, sex=Female, age=16, addr=Gun Gale Online, salary=9.99999999E8), Student(id=4, name=Yuuki, sex=Female, age=15, addr=Alfheim Online, salary=9.99999999E8), Student(id=5, name=Alice, sex=Female, age=14, addr=Alicization, salary=9.99999999E8)], true=[Student(id=2, name=Asuna, sex=Female, age=17, addr=Sword Art Online, salary=9.99999999E8)]}, true={false=[], true=[Student(id=1, name=Kirito, sex=Male, age=18, addr=Sword Art Online, salary=9.99999999E8)]}}
-----------------------------------------

{false=[Student(id=4, name=Yuuki, sex=Female, age=15, addr=Alfheim Online, salary=9.99999999E8), Student(id=3, name=Sinon, sex=Female, age=16, addr=Gun Gale Online, salary=9.99999999E8), Student(id=5, name=Alice, sex=Female, age=14, addr=Alicization, salary=9.99999999E8)], true=[Student(id=2, name=Asuna, sex=Female, age=17, addr=Sword Art Online, salary=9.99999999E8), Student(id=1, name=Kirito, sex=Male, age=18, addr=Sword Art Online, salary=9.99999999E8)]}
-----------------------------------------

文章版權(quán)歸作者所有,未經(jīng)允許請(qǐng)勿轉(zhuǎn)載,若此文章存在違規(guī)行為,您可以聯(lián)系管理員刪除。

轉(zhuǎn)載請(qǐng)注明本文地址:http://systransis.cn/yun/73351.html

相關(guān)文章

  • Stream流與Lambda達(dá)式(二) Stream收集器 Collector接口

    摘要:一收集器接口陳楊收集器接口匯聚操作的元素類型即流中元素類型匯聚操作的可變累積類型匯聚操作的結(jié)果類型接口一種可變匯聚操作將輸入元素累積到可變結(jié)果容器中在處理完所有輸入元素后可以選擇將累積的結(jié)果轉(zhuǎn)換為最終表示可選操作歸約操作 一、Stream收集器 Collector接口 package com.java.design.java8.Stream; import com.java.desi...

    or0fun 評(píng)論0 收藏0
  • Java8新特性總覽

    摘要:新特性總覽標(biāo)簽本文主要介紹的新特性,包括表達(dá)式方法引用流默認(rèn)方法組合式異步編程新的時(shí)間,等等各個(gè)方面。還有對(duì)應(yīng)的和類型的函數(shù)連接字符串廣義的歸約匯總起始值,映射方法,二元結(jié)合二元結(jié)合。使用并行流時(shí)要注意避免共享可變狀態(tài)。 Java8新特性總覽 標(biāo)簽: java [TOC] 本文主要介紹 Java 8 的新特性,包括 Lambda 表達(dá)式、方法引用、流(Stream API)、默認(rèn)方...

    mayaohua 評(píng)論0 收藏0
  • Stream流與Lambda達(dá)式(一) 雜談

    摘要:一流轉(zhuǎn)換為數(shù)組集合陳楊將流轉(zhuǎn)換為數(shù)組將流轉(zhuǎn)換為數(shù)組將流轉(zhuǎn)換為集合將流轉(zhuǎn)換為集合解析 一、流 轉(zhuǎn)換為數(shù)組、集合 package com.java.design.java8.Stream; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.boot.test.context...

    Harpsichord1207 評(píng)論0 收藏0
  • Java8學(xué)習(xí)小記

    摘要:但有一個(gè)限制它們不能修改定義的方法的局部變量的內(nèi)容。如前所述,這種限制存在的原因在于局部變量保存在棧上,并且隱式表示它們僅限于其所在線程。 2014年,Oracle發(fā)布了Java8新版本。對(duì)于Java來(lái)說(shuō),這顯然是一個(gè)具有里程碑意義的版本。尤其是那函數(shù)式編程的功能,避開(kāi)了Java那煩瑣的語(yǔ)法所帶來(lái)的麻煩。 這可以算是一篇Java8的學(xué)習(xí)筆記。將Java8一些常見(jiàn)的一些特性作了一個(gè)概要的...

    CHENGKANG 評(píng)論0 收藏0
  • 引入流

    摘要:流的使用一般包括三件事一個(gè)數(shù)據(jù)源來(lái)執(zhí)行一個(gè)查詢一個(gè)中間操作鏈,形成一條流水線一個(gè)終端操作,執(zhí)行流水線并生成結(jié)果以上便是流的一些基礎(chǔ)知識(shí),下一章會(huì)更加深入理解流。實(shí)戰(zhàn)第四章引入流讀書筆記歡迎加入咖啡館的春天。 流是什么 幾乎每個(gè) Java 應(yīng)用都會(huì)制造和處理集合。流 允許我們以聲明性方式處理集合(通過(guò)類似于 SQL 查詢語(yǔ)句來(lái)表達(dá),而不是臨時(shí)寫一個(gè)實(shí)現(xiàn))。此外 流 還可以透明地并行處理,...

    phodal 評(píng)論0 收藏0

發(fā)表評(píng)論

0條評(píng)論

閱讀需要支付1元查看
<