inheretance and ArrayList in java ..i want to know the mistake in my code
ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
inheretance and ArrayList in java ..i want to know the mistake in my code
hello every body
i am tring to solve this problem ,but i think there is smth wrong
cna any body help me
Quote:
Write a program client program that deals with different classes:
1. BankAccount class similar to the one in textbook but with additional data member accountName a string.
2. BranchBank class which consists of an arraylist of element of type BankAccount (should be protected) and an IdBranch an integer identifying the branch id. This class should contain the class constructor which reads from a file bank the branch id and the information about the accounts to be created in this branch. This class should have the following methods: searchAccount which takes as a parameter an account name and returns the corresponding BankAccount. addAccount which will add a new account in the branch.
public class BranchBank
{
// dot dot dot...
protected ArrayList<BankAccount> accounts;
}
aha. i want to write like this but it is correct to write this statement
protected ArrayList<BankAccount> accounts;
inside BranchBank without using inheretance
It's your homework, not ours. We're not going to write the rest of the code for you.
If that's not what you meant then please clarify.
you misunderstand me. I mean can you help me to correct my mistake.
beause my solution to other tasks will be wrong if these codes are wrong.
I were doing my best.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.