调用accountNo,帐户名中的ArrayList [英] Calling accountNo, accountName in ArrayLists

查看:161
本文介绍了调用accountNo,帐户名中的ArrayList的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个类的BankAccount,它构成accountNo和帐户名的getter和setter的。另外,我有一个JFrameNewAccount这将增加新帐户,并将其保存在的ArrayList。输入将文本框和单选按钮到来。

i have a class BankAccount, which compose of 'Getter and Setter' of accountNo and accountName. Also, I have a JFrameNewAccount which will add new accounts and save it in a ArrayLists. Inputs will be coming from textfields and radiobuttons.

在我JFrameNewAccount,我有一个方法:

In my JFrameNewAccount, i have a method:

ArrayList<BankAccount> list = new ArrayList<BankAccount>();

在,btnSaveActionPerformed事件我有这样的:

In, btnSaveActionPerformed event I have this:

list.add(txt_accountnumber.getText());
list.add((txt_accountname.getText()));

和它给了我一个错误发现添加(字符串)没有合适的方法
我知道那是因为ArrayList的,如果我使用ArrayList中,似乎不错,但我不知道我怎么能叫我撤架的帐号。

and it gives me an error 'No suitable method found for add(String)' I know it is because of the ArrayList, and if I used ArrayList, it seems okay, but i don't know how can i call the account number in my withdraw frame.

推荐答案

列表一点儿也不允许您添加字符串在里面。

Your list does'nt allow you to add Strings in it.

我想,你需要prepare的价值观从文本框

I guess, you need to prepare an object there with the values coming from the textfields.

BankAccount account= new BankAccount();
account.setAccountnumber(txt_accountnumber.getText());
account.setAccountname(txt_accountname.getText());
list.add(account);

每当一个新用户输入的详细信息创建一个对象,并保存到列表

这篇关于调用accountNo,帐户名中的ArrayList的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆