Checkout features in the new java REPL(read eval print loop).
Implementing concurrent programs with Actor model in Java, Scala and Kotlin.
Scala is easier than java come take a look.
Within your web app's UI there are areas that your tests interact with. A Page Object simply models these as objects within the test code. This reduces the amount of duplicated code and means that if the UI changes, the fix need only be applied in one place.
This is the basic idea behind event sourcing - instead of storing current application state, the full history of changes is stored as immutable facts and current state is derived from these facts.