Skip to content

Commit 8ae6f10

Browse files
committed
Merge pull request winterbe#8 from thefourtheye/patch-1
Fix typos and improve simple grammatical stuff
2 parents e0b308a + 17ad55b commit 8ae6f10

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

README.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ formula.calculate(100); // 100.0
7373
formula.sqrt(16); // 4.0
7474
```
7575

76-
The formula is implemented as an anonymous object. The code is quite verbose: 6 lines of code for such a simple calucation of `sqrt(a * 100)`. As we'll see in the next section, there's a much nicer way of implementing single method objects in Java 8.
76+
The formula is implemented as an anonymous object. The code is quite verbose: 6 lines of code for such a simple calculation of `sqrt(a * 100)`. As we'll see in the next section, there's a much nicer way of implementing single method objects in Java 8.
7777

7878

7979
## Lambda expressions
@@ -118,7 +118,7 @@ List now has a `sort` method. Also the java compiler is aware of the parameter t
118118

119119
## Functional Interfaces
120120

121-
How does lambda expressions fit into Javas type system? Each lambda corresponds to a given type, specified by an interface. A so called _functional interface_ must contain **exactly one abstract method** declaration. Each lambda expression of that type will be matched to this abstract method. Since default methods are not abstract you're free to add default methods to your functional interface.
121+
How does lambda expressions fit into Java's type system? Each lambda corresponds to a given type, specified by an interface. A so called _functional interface_ must contain **exactly one abstract method** declaration. Each lambda expression of that type will be matched to this abstract method. Since default methods are not abstract you're free to add default methods to your functional interface.
122122

123123
We can use arbitrary interfaces as lambda expressions as long as the interface only contains one abstract method. To ensure that your interface meet the requirements, you should add the `@FunctionalInterface` annotation. The compiler is aware of this annotation and throws a compiler error as soon as you try to add a second abstract method declaration to the interface.
124124

@@ -239,7 +239,7 @@ Writing to `num` from within the lambda expression is also prohibited.
239239

240240
### Accessing fields and static variables
241241

242-
In constrast to local variables we have both read and write access to instance fields and static variables from within lambda expressions. This behaviour is well known from anonymous objects.
242+
In contrast to local variables, we have both read and write access to instance fields and static variables from within lambda expressions. This behaviour is well known from anonymous objects.
243243

244244
```java
245245
class Lambda4 {
@@ -316,7 +316,7 @@ personSupplier.get(); // new Person
316316

317317
### Consumers
318318

319-
Consumers represents operations to be performed on a single input argument.
319+
Consumers represent operations to be performed on a single input argument.
320320

321321
```java
322322
Consumer<Person> greeter = (p) -> System.out.println("Hello, " + p.firstName);
@@ -339,7 +339,7 @@ comparator.reversed().compare(p1, p2); // < 0
339339

340340
## Optionals
341341

342-
Optionals are not functional interfaces, instead it's a nifty utility to prevent `NullPointerException`. It's an important concept for the next section, so let's have a quick look at how Optionals work.
342+
Optionals are not functional interfaces, but nifty utilities to prevent `NullPointerException`. It's an important concept for the next section, so let's have a quick look at how Optionals work.
343343

344344
Optional is a simple container for a value which may be null or non-null. Think of a method which may return a non-null result but sometimes return nothing. Instead of returning `null` you return an `Optional` in Java 8.
345345

@@ -355,7 +355,7 @@ optional.ifPresent((s) -> System.out.println(s.charAt(0))); // "b"
355355

356356
## Streams
357357

358-
A `java.util.Stream` represents a sequence of elements on which one or more operations can be performed. Stream operations are either _intermediate_ or _terminal_. While terminal operations return a result of a certain type, intermediate operations return the stream itself so you can chain multiple method calls in a row. Streams are created on a source, e.g. a `java.util.Collection` like lists or sets (maps are not supported). Stream operations can either be executed sequential or parallel.
358+
A `java.util.Stream` represents a sequence of elements on which one or more operations can be performed. Stream operations are either _intermediate_ or _terminal_. While terminal operations return a result of a certain type, intermediate operations return the stream itself so you can chain multiple method calls in a row. Streams are created on a source, e.g. a `java.util.Collection` like lists or sets (maps are not supported). Stream operations can either be executed sequentially or parallely.
359359

360360
> You should also check out [Stream.js](https://github.com/winterbe/streamjs), a JavaScript port of the Java 8 Streams API.
361361
@@ -482,7 +482,7 @@ reduced.ifPresent(System.out::println);
482482

483483
## Parallel Streams
484484

485-
As mentioned above streams can be either sequential or parallel. Operations on sequential streams are performed on a single thread while operations on parallel streams are performed concurrent on multiple threads.
485+
As mentioned above streams can be either sequential or parallel. Operations on sequential streams are performed on a single thread while operations on parallel streams are performed concurrently on multiple threads.
486486

487487
The following example demonstrates how easy it is to increase the performance by using parallel streams.
488488

@@ -600,7 +600,7 @@ Java 8 contains a brand new date and time API under the package `java.time`. The
600600

601601
### Clock
602602

603-
Clock provides access to the current date and time. Clocks are aware of a timezone and may be used instead of `System.currentTimeMillis()` to retrieve the current milliseconds. Such an instantaneous point on the time-line is also represented by the class `Instant`. Instants can be used to create legacy `java.util.Date` objects.
603+
Clock provides access to the current date and time. Clocks are aware of a timezone and may be used instead of `System.currentTimeMillis()` to retrieve the current time in milliseconds since Unix EPOCH. Such an instantaneous point on the time-line is also represented by the class `Instant`. Instants can be used to create legacy `java.util.Date` objects.
604604

605605
```java
606606
Clock clock = Clock.systemDefaultZone();
@@ -644,7 +644,7 @@ System.out.println(hoursBetween); // -3
644644
System.out.println(minutesBetween); // -239
645645
```
646646

647-
LocalTime comes with various factory method to simplify the creation of new instances, including parsing of time strings.
647+
LocalTime comes with various factory methods to simplify the creation of new instances, including parsing of time strings.
648648

649649
```java
650650
LocalTime late = LocalTime.of(23, 59, 59);
@@ -763,7 +763,7 @@ class Person {}
763763
class Person {}
764764
```
765765

766-
Using variant 2 the java compiler implicitly sets up the `@Hints` annotation under the hood. That's important for reading annotation informations via reflection.
766+
Using variant 2 the java compiler implicitly sets up the `@Hints` annotation under the hood. That's important for reading annotation information via reflection.
767767

768768
```java
769769
Hint hint = Person.class.getAnnotation(Hint.class);

0 commit comments

Comments
 (0)