Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update outdated java example in wiki #6331 #6351

Merged
merged 3 commits into from
Dec 28, 2018
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
25 changes: 12 additions & 13 deletions docs/How-To-Use-RxJava.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,21 @@ You can find additional code examples in the `/src/examples` folders of each [la
### Java

```java
public static void hello(String... names) {
Observable.from(names).subscribe(new Action1<String>() {

@Override
public void call(String s) {
System.out.println("Hello " + s + "!");
}

});
public static void main(String[] args) {
ozcanyus marked this conversation as resolved.
Show resolved Hide resolved
Flowable.just("Hello world").subscribe(System.out::println);
}
```
If your platform doesn't support Java 8 lambdas (yet), you have to create an inner class of ```Consumer``` manually:

```java
hello("Ben", "George");
Hello Ben!
Hello George!
public static void main(String[] args) {
Flowable.just("Hello world")
.subscribe(new Consumer<String>() {
@Override public void accept(String s) {
System.out.println(s);
}
});
}
```

### Groovy
Expand Down Expand Up @@ -397,4 +396,4 @@ myModifiedObservable = myObservable.onErrorResumeNext({ t ->
Throwable myThrowable = myCustomizedThrowableCreator(t);
return (Observable.error(myThrowable));
});
```
```