Java 银行项目,数组如何在数组中存储帐户的问题

Java 银行项目,数组如何在数组中存储帐户的问题,java,arrays,multidimensional-array,Java,Arrays,Multidimensional Array,这是我的代码示例 我的问题是如何在不同时输入50个帐户的情况下逐个创建一个帐户,例如,如果我只想保存10个帐户,并确保这些帐户不会写在彼此的上面,谢谢 public static void main(String[] args) { Scanner keyboard = new Scanner (System.in); String Administrator = "Amro" ;

这是我的代码示例 我的问题是如何在不同时输入50个帐户的情况下逐个创建一个帐户,例如,如果我只想保存10个帐户,并确保这些帐户不会写在彼此的上面,谢谢

public static void main(String[] args) {
                   Scanner keyboard = new Scanner (System.in);
                   String Administrator = "Amro" ;
                   String Password = "1234567";
    System.out.println("login the bank system ");
    System.out.println("1- login as Administrator ");
    System.out.println("2- login as a user ");
    System.out.println("3- Exit ");
    int x = keyboard.nextInt() ;
    switch(x){
        case 1 :               
            System.out.println("Enter username :");
            String username = keyboard.next();
            System.out.println("Enter Password :");
            String password = keyboard.next();
            if(username.equals(Administrator) && password.equals(Password)){
             System.out.println("Enter type of operation :");
                }else{ System.out.println("ERORR!!!!");
                   System.exit(0);}               
            boolean isRunning = true;
            while(isRunning){
             System.out.println("1- Create a new account");
              System.out.println("2- Deposit an amount in the account");
               System.out.println("3- Withdraw an amount in the account");
                System.out.println("4- Modify the customer data");
                 System.out.println("5- Delete the bank account");
                  System.out.println("6- Search for a bank account");
                   System.out.println("7- View all bank account");
                    System.out.println("8- Go back");
                    int y = keyboard.nextInt();
                    switch(y){
                        case 1:
                        String Info [][] = new String [50][5];
                           System.out.println("*Create a new account*");
                           for(int i=0;i<+Info.length;i++ ){
                                for(int j=0;j<1;j++){
                            System.out.println("Customer ID number :");
                           Info [i][j] = keyboard.next();
                           System.out.println("Customer Name :");
                           Info [i][j+1] = keyboard.next();
                           System.out.println("Customer password :");
                           Info [i][j+2] = keyboard.next();
                           System.out.println("Customer's phone number :");
                           Info [i][j+3] = keyboard.next();
                                }
                           }
  //                   for(int i=0;i<Info.length;i++ ){
  //                   for(int j=0;j<1;j++){
  //                  System.out.println(Info [i][j]);  
  //                   System.out.println(Info [i][j+1]);
  //                   System.out.println(Info [i][j+2]);
  //                   System.out.println(Info [i][j+3]);
  //                                      }
                   //                }
                   }

                  }
                  }
              }
          }
publicstaticvoidmain(字符串[]args){
扫描仪键盘=新扫描仪(System.in);
字符串管理员=“Amro”;
字符串密码=“1234567”;
System.out.println(“登录银行系统”);
System.out.println(“1-以管理员身份登录”);
System.out.println(“2-以用户身份登录”);
System.out.println(“3-退出”);
int x=keyboard.nextInt();
开关(x){
案例1:
System.out.println(“输入用户名:”);
字符串username=keyboard.next();
System.out.println(“输入密码:”);
字符串密码=键盘.next();
if(username.equals(管理员)和password.equals(密码)){
System.out.println(“输入操作类型:”);
}else{System.out.println(“ERORR!!!!”);
System.exit(0);}
布尔值isRunning=true;
同时(正在运行){
System.out.println(“1-创建新帐户”);
System.out.println(“2-在账户中存入金额”);
System.out.println(“3-在账户中提取金额”);
System.out.println(“4-修改客户数据”);
System.out.println(“5-删除银行账户”);
System.out.println(“6-搜索银行账户”);
System.out.println(“7-查看所有银行账户”);
System.out.println(“8-返回”);
int y=keyboard.nextInt();
开关(y){
案例1:
字符串信息[][]=新字符串[50][5];
System.out.println(“*创建新帐户*”);

对于(int i=0;i要更改此处的帐户条目数,您需要更新以下现有行:

String Info [][] = new String [50][5];
例如,如果您想输入10个帐户,您可以将其更改为:

String Info [][] = new String [10][5];
如果您想让用户输入他们计划输入的帐户数,您可以使用:

int z = keyboard.nextInt();
String Info [][] = new String [z][5];

请阅读并相应地强化您的问题。
的目的是什么(int j=0;ji think nothing i delete it谢谢!你回答了我问题的第一方面,我理解你的意思,但问题是,当我尝试创建2个帐户时,例如,第二个帐户将写在第一个帐户上。如何解决此问题对于第一个“帐户集”,你正在将其保存到信息数组中。第一个帐户保存在fo[0][],第二个帐户保存在Info[1][]中,依此类推。在第一个“集合”之后,如果用户选择输入第二组数据,则需要将现有的Info数组卸载到永久存储中(如数据库或文本文件),或者增加Info数组的大小,并确保启动迭代器(i)在先前存储的数据的最高索引加1之后,或者动态创建一个新数组,并将其添加到包含更多帐户数据的数组列表中。