Skip to content

Commit 4f0cdca

Browse files
ozcanyusakarnokd
authored andcommitted
Update outdated java example in wiki #6331 (#6351)
* Update outdated java example in wiki #6331 * update wiki page similar to README * keep the original example
1 parent 5aef7fe commit 4f0cdca

File tree

1 file changed

+14
-9
lines changed

1 file changed

+14
-9
lines changed

docs/How-To-Use-RxJava.md

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,20 @@ You can find additional code examples in the `/src/examples` folders of each [la
1111
### Java
1212

1313
```java
14-
public static void hello(String... names) {
15-
Observable.from(names).subscribe(new Action1<String>() {
16-
17-
@Override
18-
public void call(String s) {
19-
System.out.println("Hello " + s + "!");
20-
}
14+
public static void hello(String... args) {
15+
Flowable.fromArray(args).subscribe(s -> System.out.println("Hello " + s + "!"));
16+
}
17+
```
2118

22-
});
19+
If your platform doesn't support Java 8 lambdas (yet), you have to create an inner class of ```Consumer``` manually:
20+
```java
21+
public static void hello(String... args) {
22+
Flowable.fromArray(args).subscribe(new Consumer<String>() {
23+
@Override
24+
public void accept(String s) {
25+
System.out.println("Hello " + s + "!");
26+
}
27+
});
2328
}
2429
```
2530

@@ -397,4 +402,4 @@ myModifiedObservable = myObservable.onErrorResumeNext({ t ->
397402
Throwable myThrowable = myCustomizedThrowableCreator(t);
398403
return (Observable.error(myThrowable));
399404
});
400-
```
405+
```

0 commit comments

Comments
 (0)