473,383 Members | 1,876 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

a simple problem with OBSERVing funda in java .....

dmjpro
2,476 2GB
here is my code ....

Expand|Select|Wrap|Line Numbers
  1.  import java.util.*; 
  2.  
  3. class Observer1 implements Observer
  4. {
  5. public void update(Observable observed,Object o)
  6. {
  7. System.out.println("Observer1 update method: " + o);
  8. }
  9. }
  10.  
  11. class Observer2 implements Observer
  12. {
  13. public void update(Observable observed,Object o)
  14. {
  15. System.out.println("Observer2 update method: " + o);
  16. }
  17. }
  18.  
  19.  
  20. class ToBeObservable extends Observable
  21. {
  22. void test()
  23. {
  24. setChanged();
  25. notifyObservers();
  26. //System.out.println(hasChanged());
  27. }
  28. }
  29.  
  30. class TestObserv
  31. {
  32. public static void main(String args[])
  33. {
  34. ToBeObservable observed = new ToBeObservable();
  35.  
  36. Observer1 o1 = new Observer1();
  37. Observer2 o2 = new Observer2();
  38.  
  39. observed.addObserver(o1);
  40. observed.addObserver(o2);
  41.  
  42. for(int i=0;i<5;i++)
  43. observed.test();
  44.  
  45. System.out.println("Yahoo ...... tested successfully");
  46. }
  47. }
  48.  
in which order the the update method will call ... i mean in which order the observers are notified ....

plz explain me ..... thanx in advance ....
Mar 6 '07 #1
0 906

Sign in to post your reply or Sign up for a free account.

Similar topics

10
by: martin | last post by:
Hello, I just got the SUN Java IDE. (Netbeans IDE 3.5.1) Very very nice, and I worked myself through the tutorial (about making a colorswitch). Now, When I compile it gives no errors at all. So...
4
by: Stefan Poehn | last post by:
Hi does anybody know a tool that converts Java-Code to C++? I need a very simple converter that does NOT need to cover Threading, Swing, Exceptions, Reflection, RMI, Security, Networking and...
2
by: Spare Brain | last post by:
Hi, I am observing a strange error with the time portion of the java.sql.Date() when using resultSet.getDate() - it always seems to show 12:00:00. The following code prints 2004-10-27...
6
by: freakyfreak | last post by:
Does anyone have any basic, simple scripts of sp's that I can give my computer operators to use to monitor for serious conditions on our sql servers? We are new in the ms-sql arena, a small shop...
21
by: Pedro Salazar | last post by:
Hi, I have a new machine with Intel Desktop Board D865GBF. 3GHz. A simple program like this (I explain later) takes TEN times more to complete than in my older machine with 1.7GHz, D850MV. ...
14
by: Jigar Mehta | last post by:
Hye all, I am a VC++ programmer (have exp. of 2+ years).. But till now, I have never worked on templates.. I have developed whole products but never worked on templates or used them in my...
3
dmjpro
by: dmjpro | last post by:
i have been working with IO handling for 3-4 months. but still i not understood the funda of the three methods .... MARK,RESET,SKIP provided for IO handling. plz explain these methods with...
28
by: parag_paul | last post by:
http://concentratedlemonjuice.blogspot.com/2008/06/about-c-puzzles-on-my-blog.html I actually am searching for more work done on C now, today there are many sites that will provide you college...
5
by: sayeo87 | last post by:
Hi, I am quite new to JSP so please forgive me if I ask really simple things... I am trying to run system commands on the server and display the output on a webpage. This is what I've got: <%@...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.