
March 18th, 2007, 06:53 PM
|
|
Registered User
|
|
Join Date: Feb 2006
Posts: 2
Time spent in forums: 1 h 13 m 14 sec
Reputation Power: 0
|
|
|
Child Objects Sharing Memory With Parent
Hello,
I'm pretty new to java, so I'm pretty frustrated with this. I am creating a banking type system with the parent "Account" class having most of the banking operations (deposit, withdraw, view balance) and the "Checking" and "Savings" classes inheriting from the account class with their own specific operations.
My assignment says to create 1 object of account and 2 each of checking and savings. I declare them as
Object account 1 = new Account()
Object checking1 = new CheckingAccount( )
Object checking2 = new CheckingAccount( )
...and so on
Everything works fine until I actually attempt to put in information into the classes. For example, no matter which account of the 5 I deposit money to, they all show that money has been added. I don't exactly get why they would all share the same memory space, but I'm sure it's something I did wrong. Any help would be greatly appreciated.
|