This week's book giveaway is in the OCMJEA forum. We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line! See this thread for details.
i've 2 class, in class ProgCalc i've got a method that set a choose from a menu. I create "t" an object TimeOfDay, and i get its value, than i create another object TimeOfDay "t1". t1 overwrite t... why?
[ March 27, 2006: Message edited by: Antony Amicone ]
If a member variable is "static", it means it is shared by all instances of the class. Therefore although t and t1 are pointing to distinct instances of your class, they share all their member data. If t makes a change, t1 sees that change, and vice-versa.
Remove every single instance of "static" in the TimeOfDay class, and things will be fixed -- or at least close to fixed. Then go back and remove every single use of "static" in ProgTime, as well, except for the one in "public static void main()". Finally, change the call to printHome() to something like