Book Image

The Java Workshop

By : David Cuartielles, Andreas Göransson, Eric Foster-Johnson
Book Image

The Java Workshop

By: David Cuartielles, Andreas Göransson, Eric Foster-Johnson

Overview of this book

Java is a versatile, popular programming language used across a wide range of industries. Learning how to write effective Java code can take your career to the next level, and The Java Workshop will help you do just that. This book is designed to take the pain out of Java coding and teach you everything you need to know to be productive in building real-world software. The Workshop starts by showing you how to use classes, methods, and the built-in Collections API to manipulate data structures effortlessly. You’ll dive right into learning about object-oriented programming by creating classes and interfaces and making use of inheritance and polymorphism. After learning how to handle exceptions, you’ll study the modules, packages, and libraries that help you organize your code. As you progress, you’ll discover how to connect to external databases and web servers, work with regular expressions, and write unit tests to validate your code. You’ll also be introduced to functional programming and see how to implement it using lambda functions. By the end of this Workshop, you’ll be well-versed with key Java concepts and have the knowledge and confidence to tackle your own ambitious projects with Java.
Table of Contents (20 chapters)

Subscriber

The subscriber represents the end-user. It receives the data at the very end of the stream and acts on it. The action may include updating a user interface, pushing it to another component, or transforming it in any way.

The interface of the subscribers contains four different callbacks, each of which represents a message of some type from the publisher or the subscriber itself:

  • onSubscribe: The onSubscribe method is invoked as soon as the subscriber has a valid subscription. Generally, this is used to kick-start the delivery of items from the publisher. The Subscriber will typically inform the Publisher here, by requesting another item.
  • onNext: The onNext method is invoked when another item is made available from the Publisher.
  • onError: The onError method is invoked when an error occurs. This usually means that the subscriber will no longer receive any more messages and should be closed down.
  • onComplete: The onComplete method is invoked by the publisher...