First of all, to recommend a good place: http://ifeve.com/stream/can learn a bit
Next, we're going to delete some elements of the array today, thinking about the JDK8 stream that I used before.
1.Array Convert to stream and filter
"There's a pit: There are two ways to convert an array to stream
1.stream.of (Array)
2.arrays.stream (Array)
Difference: Both support reference data types, but if it is the basic data type, choose the second one, so it is appropriate to use the second in proper period.
】
The code is as follows:
@org. Junit.test Public void throws ioexception{ = "2.1.1&2.1.2&2.1.5&2.1.6&3.1.1&3.2.2&3.3.3&4.1.1& 4.1.2&4.1.4&5.1.2&7.1.2&7.2.1&7.3.1.1&7.3.3.1&7.3.4.3&7.3.5.2&7.3.6.2& 7.3.6.3 ". Split (" & "); Stream<String> stream = arrays.stream (str); = Stream.filter (S-s.contains ("2.1.") ) . ToArray (); for (int i = 0; i < o1.length; i++) { System.out.println (str[i].tostring ()); } }
2.List Collection converted to stream
"Collection. Stream () can"
Use of the "Java" stream