void (String... args) { Observable<String> obs = create((Observer<? super String> o) -> { o.onNext("one"); o.onNext("two"); o.onCompleted(); }); obs.subscribe(new Observer<String>() { @Override public void onCompleted() { System.out.println("Completed"); } @Override public void onError(Throwable e) { System.out.println("Error"); } @Override public void onNext(String v) { System.out.println("Value: " + v); } }); Observable<String> obs2 = create(new OnSubscribeFunc<String>() { @Override public void onSubscribe(Observer<? super String> o) { o.onNext("one"); o.onNext("two"); o.onCompleted(); } }); obs2.subscribe(new Observer<String>() { @Override public void onCompleted() { System.out.println("Completed"); } @Override public void onError(Throwable e) { System.out.println("Error"); } @Override public void onNext(String v) { System.out.println("Value: " + v); } }); }