diff --git a/data/part-10/1-handling-collections-as-streams.md b/data/part-10/1-handling-collections-as-streams.md index 076593d3e..f7b2d59a5 100644 --- a/data/part-10/1-handling-collections-as-streams.md +++ b/data/part-10/1-handling-collections-as-streams.md @@ -216,7 +216,7 @@ A brief summary of the stream methods we've encountered so far. - Stream formation: `stream()` + Stream formation: stream() The method is called on collection that implements the Collection interface, such as an ArrayList Object. Something is done on the created stream. @@ -225,7 +225,7 @@ A brief summary of the stream methods we've encountered so far. - Converting a stream into an integer stream: `mapToInt(value -> another)` + Converting a stream into an integer stream: mapToInt(value -> another) The stream transforms into one containing integers. @@ -237,30 +237,30 @@ A brief summary of the stream methods we've encountered so far. Filtering values: - `filter(value -> filter condition)` + filter(value -> filter condition) The elements that do not satisfy the filter condition are removed from the string. On the right side of the arrow is a statement that returns a boolean. - If the boolean is `true`, the element is accepted into the stream. If the boolean evaluates to false, the value is not accepted into the stream. Something is done with the filtered values. + If the boolean is true, the element is accepted into the stream. If the boolean evaluates to false, the value is not accepted into the stream. Something is done with the filtered values. - Calculating the average: `average()` + Calculating the average: average() - Returns a OptionalDouble-type object that has a method `getAsDouble()` that returns a value of type `double`. Calling the method `average()` works on streams that contain integers - they can be created with the `mapToInt` method. + Returns a OptionalDouble-type object that has a method getAsDouble() that returns a value of type double. Calling the method average() works on streams that contain integers - they can be created with the mapToInt method. - Counting the number of elements in a stream: `count()` + Counting the number of elements in a stream: count() - Returns the number of elements in a stream as a `long`-type value. + Returns the number of elements in a stream as a long-type value. @@ -1288,7 +1288,7 @@ The exercise template includes the probably familiar project "Cargo hold". Howev -

Streams are also very handy in handling files. The file is read in stream form using Java's ready-made Files class. The `lines` method in the files class allows you to create an input stream from a file, allowing you to process the rows one by one. The `lines` method gets a path as its parameter, which is created using the `get` method in the Paths class. The `get` method is provided a string describing the file path.

+

Streams are also very handy in handling files. The file is read in stream form using Java's ready-made Files class. The lines method in the files class allows you to create an input stream from a file, allowing you to process the rows one by one. The lines method gets a path as its parameter, which is created using the get method in the Paths class. The get method is provided a string describing the file path.

The example below reads all the lines in "file.txt" and adds them to the list. diff --git a/data/part-9/2-interfaces.md b/data/part-9/2-interfaces.md index fe184b532..9ec9164fa 100644 --- a/data/part-9/2-interfaces.md +++ b/data/part-9/2-interfaces.md @@ -1055,7 +1055,7 @@ Using interfaces in programming enables reducing dependencies between classes. I -

The List interface defines the basic functionality related to lists. Because the ArrayList class implements the `List` interface, one can also use it through the `List` interface.

+

The List interface defines the basic functionality related to lists. Because the ArrayList class implements the List interface, one can also use it through the List interface.


@@ -1071,7 +1071,7 @@ strings.add("string objects inside an arraylist object!"); -

As we can see fom the Java API of List, there are many classes that implement the `List` interface. One list that is familiar to computer scientists is a linked list. A linked list can be used through the List interface exactly the same way as an object created from ArrayList.

+

As we can see fom the Java API of List, there are many classes that implement the List interface. One list that is familiar to computer scientists is a linked list. A linked list can be used through the List interface exactly the same way as an object created from ArrayList.