Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pitfalls of Event Handling in Java

I'm working on a program that needs a Java object to have an event. I'm quite familiar with how this works in C#, having had enough experience to learn the pitfalls.

What are the pitfalls of working with events in Java? How are they different from events in C# 2.0?

Example: An object changed event to prompt a save from the owner object.

Note: Java 1.5

Related: C# event handling (compared to Java)

like image 509
C. Ross Avatar asked May 15 '26 13:05

C. Ross


1 Answers

Java has no built-in concept of events, so you are best off using variations of The Observer Pattern.

like image 190
matt b Avatar answered May 18 '26 01:05

matt b