diff --git a/docs/How-To-Use-RxJava.md b/docs/How-To-Use-RxJava.md index d10274d959..16d156caa9 100644 --- a/docs/How-To-Use-RxJava.md +++ b/docs/How-To-Use-RxJava.md @@ -11,15 +11,20 @@ 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() { - - @Override - public void call(String s) { - System.out.println("Hello " + s + "!"); - } +public static void hello(String... args) { + Flowable.fromArray(args).subscribe(s -> System.out.println("Hello " + s + "!")); +} +``` - }); +If your platform doesn't support Java 8 lambdas (yet), you have to create an inner class of ```Consumer``` manually: +```java +public static void hello(String... args) { + Flowable.fromArray(args).subscribe(new Consumer() { + @Override + public void accept(String s) { + System.out.println("Hello " + s + "!"); + } + }); } ``` @@ -397,4 +402,4 @@ myModifiedObservable = myObservable.onErrorResumeNext({ t -> Throwable myThrowable = myCustomizedThrowableCreator(t); return (Observable.error(myThrowable)); }); -``` \ No newline at end of file +```