java實現(xiàn)銀行ATM管理系統(tǒng)
本文實例為大家分享了java實現(xiàn)銀行ATM管理系統(tǒng)的具體代碼,供大家參考,具體內(nèi)容如下
功能
賬戶類、首頁設(shè)計
分析
① 每個用戶一個賬戶對象,需要設(shè)計賬戶類,賬戶類至少包含(卡號、用戶名、余額、取現(xiàn)額度、密碼)
② 需要定義一個ArrayList的集合用于存儲賬戶對象。
③ 需要展示歡迎頁包含2個功能:注冊開戶、登錄賬戶。
用戶開戶功能實現(xiàn)
① 開戶功能應(yīng)該獨立定義成方法,并傳入當(dāng)前集合對象給該方法。
public static void register(ArrayList<Account> accounts) {…}
② 需要提示用戶輸入個人信息,開戶的卡號是系統(tǒng)自動生成的8位數(shù)。
public static String createCardId(){…}
③ 注意:自動生成的卡號不能與其他用戶的卡號重復(fù)。
④ 最終把用戶開戶的信息封裝成Account對象,存入到集合中。
用戶登錄功能實現(xiàn)
分析
① 需要根據(jù)卡號去集合中查詢對應(yīng)的賬戶對象。
② 如果找到了賬戶對象,說明卡號存在,繼續(xù)輸入密碼。
③ 如果密碼也正確,則登錄成功。
用戶操作頁設(shè)計、查詢賬戶、退出賬戶功能
分析
① 用戶登錄成功后,需要進入用戶操作頁。
② 查詢就是直接展示當(dāng)前登錄成功的賬戶對象的信息。
③ 退出賬戶是需要回到首頁的
用戶存款、取款功能設(shè)計
分析
① 存款和取款都是拿到當(dāng)前用戶的賬戶對象。
② 通過調(diào)用賬戶對象的set方法修改其余額。
用戶轉(zhuǎn)賬功能設(shè)計
分析
① 轉(zhuǎn)賬功能要分析對方賬戶是否存在的問題。
② 還要分析自己的余額是否足夠的問題。
用戶密碼修改功能、銷戶功能
分析
① 修改密碼就是把當(dāng)前對象的密碼屬性使用set方法進行更新。
② 銷戶是從集合對象中刪除當(dāng)前對象,并回到首頁。
輸出流
import java.util.ArrayList; import java.util.Random; import java.util.Scanner;
首頁設(shè)計
public class Bank { ? ? public static void main(String[] args) { ? ? ? ? Scanner sc = new Scanner(System.in); ? ? ? ? ArrayList<Account> list = new ArrayList<>(); ? ? ? ? ? //首頁設(shè)計 ? ? ? ? while(true){//while死循環(huán) ? ? ? ? ? System.out.println("========歡迎您進入萬和銀行ATM系統(tǒng)========"); ? ? ? ? System.out.println("1.登錄賬戶"); ? ? ? ? System.out.println("2.注冊開戶"); ? ? ? ? System.out.println("請輸入命令1、2選擇對應(yīng)的操作");
首頁界面選擇
//首頁界面選擇 String choice =sc.next(); ? ?switch (choice){//switch語句使輸入的指令進入不同的功能 ? ? ? ? ? ? ? ? case "1": ? ? ? ? ? ? ? ? ? ? System.out.println("========歡迎您進入萬和銀行用戶登錄界面========"); ? ? ? ? ? ? ? ? ? ? login(list); ? ? ? ? ? ? ? ? ? ? break; ? ? ? ? ? ? ? ? case "2": ? ? ? ? ? ? ? ? ? ? System.out.println("========歡迎您進入萬和銀行用戶辦卡界面========"); ? ? ? ? ? ? ? ? ? ? register(list); ? ? ? ? ? ? ? ? ? ? break; ? ? ? ? ? ? ? ? case "后臺統(tǒng)計"://為后臺統(tǒng)計數(shù)據(jù)使用,主界面直接輸入“后臺統(tǒng)計”可以顯示系統(tǒng)所有成員信息 ? ? ? ? ? ? ? ? ? ? System.out.println("========后臺統(tǒng)計========"); ? ? ? ? ? ? ? ? ? ? htlook(list); ? ? ? ? ? ? ? ? ? ? break; ? ? ? ? ? ? ? ? default: ? ? ? ? ? ? ? ? ? ? System.out.println("您輸入的數(shù)字有誤,請重新輸入"); ? ? ? ? ?} ? ? } }
1、用戶登錄功能
// ?1、用戶登錄功能 public static void login(ArrayList<Account> list) { ? ? ? ? ? ? Scanner sc = new Scanner(System.in);//創(chuàng)建鍵盤錄入對象 ? ? ? ? ? ? ? System.out.println("請輸入您的卡號"); ? ? ? ? ? ? String idcard = sc.next(); ? ? ? ? ? ? ? int index = getIndex(list, idcard);//調(diào)用方法判斷后臺是否有該卡號 ? ? ? ? ? ? if (index == -1) { ? ? ? ? ? ? ? ? System.out.println("不存在該卡號,請重新輸入"); ? ? ? ? ? ? } else { ? ? ? ? ? ? ? ? for (int i = 0; i < list.size(); i++) { ? ? ? ? ? ? ? ? ? ? System.out.println("請您輸入您的密碼"); ? ? ? ? ? ? ? ? ? ? String password = sc.next(); ? ? ? ? ? ? ? ? ? ? ? if (password.equals(list.get(index).getPassword())){//如果輸入的卡號的索引index與該索引下的密碼一致則登錄成功 ? ? ? ? ? ? ? ? ? ? ? ? System.out.println("萬和" + list.get(index).getUsername() +"貴賓,歡迎您進入系統(tǒng),您的卡號:" + list.get(index).getId()); ? ? ? ? ? ? ? ? ? ? ? ? System.out.println(); ? ? ? ? ? ? ? ? ? ? ? ? ? while(true){//卡號密碼成功,進入用戶界面 ? ? ? ? ? ? ? ? ? ? ? ? ? ? System.out.println("==========歡迎您進入萬和銀行用戶操作界面=========="); ? ? ? ? ? ? ? ? ? ? ? ? ? ? System.out.println("1 ? 查詢"); ? ? ? ? ? ? ? ? ? ? ? ? ? ? System.out.println("2 ? 存款"); ? ? ? ? ? ? ? ? ? ? ? ? ? ? System.out.println("3 ? 取款"); ? ? ? ? ? ? ? ? ? ? ? ? ? ? System.out.println("4 ? 轉(zhuǎn)賬"); ? ? ? ? ? ? ? ? ? ? ? ? ? ? System.out.println("5 ? 修改密碼"); ? ? ? ? ? ? ? ? ? ? ? ? ? ? System.out.println("6 ? 退出"); ? ? ? ? ? ? ? ? ? ? ? ? ? ? System.out.println("7 ? 注銷當(dāng)前賬戶"); ? ? ? ? ? ? ? ? ? ? ? ? ? ? System.out.println("請輸入您要輸入的功能"); ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? String choice = sc.next();//用戶輸入 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? switch (choice){ ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? case "1": ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? System.out.println("==========歡迎您進入萬和銀行用戶詳情界面========="); ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? querymessage(list, index);//查詢個人信息方法 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? break ; ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? case "2": ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? System.out.println("==========歡迎您進入萬和銀行用戶存款界面========="); ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? inmoney(list, sc, index); //存款 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? break; ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? case "3": ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? System.out.println("==========歡迎您進入萬和銀行用戶取款界面========="); ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? outmoney(list, sc, index); //取款 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? break; ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? case "4": ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? System.out.println("==========歡迎您進入萬和銀行用戶轉(zhuǎn)賬界面========="); ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? transfer(list, sc, index);//轉(zhuǎn)賬功能 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? break; ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? case "5": ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? System.out.println("==========歡迎您進入萬和銀行用戶密碼修改界面========="); ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? revisePassword(list, sc, index);//修改密碼 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? return; ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? case "6": ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? System.out.println("退出"); ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? return;//結(jié)束整個方法,回到主界面 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? case "7"://用戶注銷 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? System.out.println("==========歡迎您進入萬和銀行用戶注銷界面========="); ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? System.out.println("您確定要注銷該賬戶?"); ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? System.out.println("1 ? 確定"); ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? System.out.println("按任意鍵返回上一頁"); ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? System.out.println("請輸入您要輸入的選項"); ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? String choice0 = sc.next(); ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? switch (choice0){ ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? case "1": ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? Account ac = list.get(index); ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? while(true){ ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? System.out.println("請輸入當(dāng)前賬戶的密碼"); ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? String key = sc.next(); ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? if (key.equals(ac.getPassword())){ ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? list.remove(index); ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? System.out.println("注銷成功,將返回主界面"); ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? return; ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? } ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? } ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? default: ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? break; ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? } ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? break; ? ? ? ? ? ? ? ? ? ? ? ? ? ? } ? ? ? ? ? ? ? ? ? ? ? ? } ? ? ? ? ? ? ? ? ? ? }else ? ? ? ? ? ? ? ? ? ? ? ? { ? ? ? ? ? ? ? ? ? ? ? ? ? ? System.out.println("您輸入的密碼有誤,請確認"); ? ? ? ? ? ? ? ? ? ? } ? ? ? ? ? ? ? ? } ? ? ? ? ? ? } ? ? ? ? }
轉(zhuǎn)賬功能
//轉(zhuǎn)賬功能 private static void transfer(ArrayList<Account> list, Scanner sc, int index) { ? ?Account acc = list.get(index);//將集合list在index索引下的數(shù)據(jù)傳入acc ? ? ? ? int num = list.size();//獲取集合長度 ? ? ? ? if(num < 2){//如果集合長度小于二,不能轉(zhuǎn)賬 ? ? ? ? ? ? System.out.println("當(dāng)前系統(tǒng)不足兩個,不能轉(zhuǎn)賬"); ? ? ? ? }else{ ? ? ? ? ? ? if(acc.getBalance() < 100){//余額小于100,不能轉(zhuǎn)賬 ? ? ? ? ? ? ? ? System.out.println("余額不足"); ? ? ? ? ? ? }else { ? ? ? ? ? ? ? ? while(true){ ? ? ? ? ? ? ? ? ? ? System.out.println("請輸入要轉(zhuǎn)賬的賬號"); ? ? ? ? ? ? ? ? ? ? String anotherId = sc.next(); ? ? ? ? ? ? ? ? ? ? int anotherIdIndex = getIndex(list,anotherId);//判斷賬號在系統(tǒng)中是否存在 ? ? ? ? ? ? ? ? ? ? if (anotherIdIndex == -1){//如果返回-1,不存在 ? ? ? ? ? ? ? ? ? ? ? ? System.out.println("您輸入的賬戶不存在,請重新確認"); ? ? ? ? ? ? ? ? ? ? }else{ ? ? ? ? ? ? ? ? ? ? ? ? Account acc1 = list.get(anotherIdIndex);//將剛剛輸入的索引下的數(shù)據(jù)傳入acc1,留作接下來修改 ? ? ? ? ? ? ? ? ? ? ? ? String name = acc1.getUsername(); ? ? ? ? ? ? ? ? ? ? ? ? char firstName = name.charAt(0);//獲取用戶名的姓氏 ? ? ? ? ? ? ? ? ? ? ? ? String xname = name.replace(firstName,'*');//將用戶名的姓氏變?yōu)?輸出 ? ? ? ? ? ? ? ? ? ? ? ? System.out.println("您當(dāng)前要為" + xname + "轉(zhuǎn)賬"); ? ? ? ? ? ? ? ? ? ? ? ? System.out.println("請您輸入姓氏確認:"); ? ? ? ? ? ? ? ? ? ? ? ? String ?firstname = sc.next(); ? ? ? ? ? ? ? ? ? ? ? ? char chr = firstname.charAt(0);//輸入的姓氏和系統(tǒng)的姓氏對比 ? ? ? ? ? ? ? ? ? ? ? ?if(chr == firstName){//如果相等,都是char形式才能比較 ? ? ? ? ? ? ? ? ? ? ? ? ? ?System.out.println("輸入正確"); ? ? ? ? ? ? ? ? ? ? ? ? ? ?while(true){ ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?System.out.println("請輸入要轉(zhuǎn)入的金額:"); ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?double sendmoney = sc.nextDouble(); ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?if(sendmoney < list.get(index).getEnchashment()){ ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?System.out.println("您當(dāng)前轉(zhuǎn)賬超過了當(dāng)次限額!"); ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?} ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?else if(sendmoney > list.get(index).getBalance()){ ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?System.out.println("您的余額不足"); ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?}else{ ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?acc.setBalance(list.get(index).getBalance() - sendmoney);//對自己的金額扣錢 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?acc.setBalance(list.get(anotherIdIndex).getBalance() + sendmoney);//對別人的賬戶打款 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?System.out.println("轉(zhuǎn)賬成功"); ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?return; ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?} ? ? ? ? ? ? ? ? ? ? ? ? ? ?} ? ? ? ? ? ? ? ? ? ? ? ?} ? ? ? ? ? ? ? ? ? ? } ? ? ? ? ? ? ? ? } ? ? ? ? ? ? } ? ? ? ? } ? ? }
修改密碼
//修改密碼 private static void revisePassword(ArrayList<Account> list, Scanner sc, int index) { ? ?Account acc = list.get(index); ? ? ? ? while (true){ ? ? ? ? ? ? System.out.println("請您輸入當(dāng)前賬戶密碼:"); ? ? ? ? ? ? String nowpassword = sc.next(); ? ? ? ? ? ? if (nowpassword.equals(acc.getPassword())){//看原來的密碼是否輸入正確 ? ? ? ? ? ? ? ? System.out.println("請您輸入新的密碼:"); ? ? ? ? ? ? ? ? String newpassword = sc.next(); ? ? ? ? ? ? ? ? list.get(index).setPassword(newpassword);//set功能將新的密碼寫入系統(tǒng) ? ? ? ? ? ? ? ? System.out.println("密碼修改成功請您重新登錄"); ? ? ? ? ? ? ? ? return; ? ? ? ? ? ? }else{ ? ? ? ? ? ? ? ? System.out.println("當(dāng)前賬戶密碼不正確"); ? ? ? ? ? ? } ? ? ? ? } ? ? }
取款
//取款 private static void outmoney(ArrayList<Account> list, Scanner sc, int index) { ? ?Account acc = list.get(index); ? ? ? ? if (list.get(index).getBalance() < 100){ ? ? ? ? ? ? System.out.println("余額不足100元,無法取出,請存入金額!"); ? ? ? ? }else{ ? ? ? ? ? ? while(true){ ? ? ? ? ? ? ? ? System.out.println("請輸入取款的金額"); ? ? ? ? ? ? ? ? double outmoney = sc.nextDouble(); ? ? ? ? ? ? ? ? ? if(outmoney < list.get(index).getEnchashment()){ ? ? ? ? ? ? ? ? ? ? System.out.println("您當(dāng)前取款超過了當(dāng)次限額!"); ? ? ? ? ? ? ? ? }else if(list.get(index).getBalance()- outmoney < 0){ ? ? ? ? ? ? ? ? ? ? System.out.println("您的賬戶余額不足"); ? ? ? ? ? ? ? ? }else{ ? ? ? ? ? ? ? ? ? ? acc.setBalance(list.get(index).getBalance() - outmoney); ? ? ? ? ? ? ? ? ? ? System.out.println("您已取款成功!"); ? ? ? ? ? ? ? ? ? ? break; ? ? ? ? ? ? ? ? } ? ? ? ? ? ? } ? ? ? ? } ? ? }
查詢個人信息方法
//查詢個人信息方法 ? ? private static void querymessage(ArrayList<Account> list, int index) { ? ? ? ? System.out.println("您的賬戶信息如下:"); ? ? ? ? for (int i1 = 0; i1 < list.size(); i1++) {//遍歷 ? ? ? ? ? ? Account acc = list.get(index);//將數(shù)據(jù)導(dǎo)進來 ? ? ? ? ? ? System.out.println("卡號:" + acc.getId()); ? ? ? ? ? ? System.out.println("姓名:" + acc.getUsername()); ? ? ? ? ? ? System.out.println("余額:" + acc.getBalance()); ? ? ? ? ? ? System.out.println("當(dāng)次取現(xiàn)額度:" + acc.getEnchashment()); ? ? ? ? } ? ? }
存款
//存款 ? ? private static void inmoney(ArrayList<Account> list, Scanner sc, int index) { ? ? ? ? System.out.println("請您輸入存款的金額"); ? ? ? ? double inmoney = sc.nextDouble(); ? ? ? ? Account acc = list.get(index); ? ? ? ? acc.setBalance(list.get(index).getBalance() + inmoney) ;//集合list中的值為index的索引下的余額balance 加 剛剛存入的金額inmoney ? ? ? ? System.out.println("您已經(jīng)存款成功"); ? ? }
2、用戶開戶功能
// 2、用戶開戶功能 public static void register(ArrayList<Account> list){ ? ? ? ? Scanner sc = new Scanner(System.in); ? ? ? ? ? System.out.println("請您輸入您的姓名:"); ? ? ? ? String username = sc.next(); ? ? ? ? ? String password; ? ? ? ? while(true){ ? ? ? ? ? ? System.out.println("請您輸入您的密碼:"); ? ? ? ? ? ? String password1 = sc.next(); ? ? ? ? ? ? System.out.println("請您再次確認密碼:"); ? ? ? ? ? ? String password2 = sc.next(); ? ? ? ? ? ? if (password1.equals(password2)){ ? ? ? ? ? ? ? ? password = password2; ? ? ? ? ? ? ? ? break; ? ? ? ? ? ? }else{ ? ? ? ? ? ? ? ? System.out.println("兩次密碼不一致,請重新輸入"); ? ? ? ? ? ? } ? ? ? ? } ? ? ? ? System.out.println(password); ? ? ? ? ? System.out.println("請設(shè)置當(dāng)日取現(xiàn)額度:"); ? ? ? ? double enchashment = sc.nextDouble(); ? ? ? ? ? //自動生成八位數(shù)卡號并檢測是否重復(fù) ? ? ? ? Random r = new Random(); ? ? ? ? String s = new String(); ? ? ? ? while(true) { ? ? ? ? ? ? for (int i = 0; i < 8; i++) { ? ? ? ? ? ? ? ? int num = r.nextInt(10); ? ? ? ? ? ? ? ? s += num; ? ? ? ? ? ? } ? ? ? ? ? ? int index = getIndex(list, s);//調(diào)用getIndex方法返回-1則沒有重復(fù) ? ? ? ? ? ? if (index == -1){ ? ? ? ? ? ? ? ? break; ? ? ? ? ? ? } ? ? ? ? } ? ? ? ? ? //設(shè)置賬戶余額 ? ? ? ? double balance = 0; ? ? ? ? Account acc = new Account(s,username,enchashment,password,balance); ? ? ? ? list.add(acc); ? ? ? ? System.out.println("萬和" + username + "貴賓,您的賬戶已經(jīng)開卡成功,您的卡號是:" + s); ? ? ? ? }
//獲取集合中的用戶的索引and判斷集合中是否有該對象 private static int getIndex(ArrayList<Account> list, String s) { ? ? ? ? int index = -1;//假設(shè)新生成的卡號,在集合中不存在 ? ? ? ? for (int i = 0; i < list.size(); i++) {//遍歷集合,獲取每一個對象,準備進行查找 ? ? ? ? ? ? Account ac = list.get(i);//類名 對象名 = 集合名.get(i); ? ? ? ? ? ? String idcard = ac.getId();//獲取每一個對象的學(xué)號叫id ? ? ? ? ? ? if(idcard.equals(s)){//判斷獲取過的id和新生成的s是否一樣,如果相同賦值給index ? ? ? ? ? ? ? ? index = i;//存在,讓index變量記錄對象的索引值 ? ? ? ? ? ? } ? ? ? ? } ? ? ? ? return index; ? ? } ? ? //查看信息(后臺統(tǒng)計) ? ? public static void htlook(ArrayList<Account> list){ ? ? ? ? for (int i = 0; i < list.size(); i++) { ? ? ? ? ? ? Account acc = list.get(i); ? ? ? ? ? ? System.out.println(acc.getId()+" ? ?" + acc.getEnchashment() + " ? " + acc.getUsername() + " ? ?" + acc.getPassword() + " ? " + acc.getBalance()); ? ? ? ? } ? ? } }
以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
相關(guān)文章
基于RxPaparazzo實現(xiàn)圖片裁剪、圖片旋轉(zhuǎn)、比例放大縮小功能
這篇文章主要為大家詳細介紹了基于RxPaparazzo實現(xiàn)圖片裁剪、圖片旋轉(zhuǎn)、比例放大縮小功能,具有一定的參考價值,感興趣的小伙伴們可以參考一下2017-05-05Springboot+Mybatis-plus不使用SQL語句進行多表添加操作及問題小結(jié)
這篇文章主要介紹了在Springboot+Mybatis-plus不使用SQL語句進行多表添加操作,本文給大家介紹的非常詳細,對大家的學(xué)習(xí)或工作具有一定的參考借鑒價值,需要的朋友可以參考下2023-04-04Java實戰(zhàn)之校園外賣點餐系統(tǒng)的實現(xiàn)
這篇文章主要介紹了如何利用Java實現(xiàn)簡易的校園外賣點餐系統(tǒng),文中采用的技術(shù)有:JSP、Spring、SpringMVC、MyBatis 等,感興趣的可以了解一下2022-03-03