java.util.Arrays$ArrayList cannot be cast to java.util.Iterator

报错:

java.util.Arrays$ArrayList cannot be cast to java.util.Iterator

原代码

JavaRDD<String> words=input.flatMap(new FlatMapFunction<String, String>() {
            @Override
            public Iterator<String> call(String s) throws Exception {
                return (Iterator<String>)Arrays.asList(s.split(" "));
            }
        });

更新后的代码

JavaRDD<String> words=input.flatMap(new FlatMapFunction<String, String>() {
            @Override
            public Iterator<String> call(String s) throws Exception {
                return Arrays.asList(s.split(" ")).iterator();
            }
        });

你可能感兴趣的:(报错修复)