1. 程式人生 > >RxJava2 Flowable cast

RxJava2 Flowable cast

   @Test
    public void cast() {
        System.out.println("######cast#####");
        List<Float> source = new ArrayList<>();
        source.add(199f);
        source.add(102f);
        source.add(100f);
        Flowable flowable = Flowable.fromIterable(source);

        flowable.cast(Number.class).subscribe(new
Consumer<Number>() { @Override public void accept(Number number) throws Exception { System.out.println(number); } }); } 測試結果 ######cast##### 199.0 102.0 100.0 Process finished with exit code 0