I want to do something like this in Java but I don’t know the way:
When event “object 1 say ‘hello'” happens,
then object 2 responds to that event by saying “hello”.
Can somebody give me a hint or sample code?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You probably want to look into the observer pattern.
Here’s some sample code to get yourself started:
Related article: Java: Creating a custom event