• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

Observer and Observable

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Can someone please give me a better idea about what these two classes do? (Yes, I am an OOP newbie, and no, I can't afford the latest whizz-bang book!
;-) ).
If possible, some code showing how they work will be even better, as I tend to grasp things a little better when I get to play with the code and see what works and what does not.
 
Ranch Hand
Posts: 146
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Evan,
BTW - Observer is an interface rather than a class.
A class can implement an Observer interface when it wishes to tell other objects that some event of common interest is going to happen. Suppose, I am trying to write an online chat application and one of the condition is that every client that is connected to the chat server should be updated everytime any one says something.
So we might have Chat session to be an Observable and each client to be implementing Observer interface. So it lets you brodcast event notification to any number of interested clients.
Check out the further details here:
http://www.javaworld.com/javaworld/jw-10-1996/jw-10-howto.html

Regards,
Milind
 
If you look closely at this tiny ad, you will see five bicycles and a naked woman:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic