class Response { String name; long id; List<Account> accounts; } // .. public class AccountsConverter implements JsonDeserializer<List<Account>> { public List<Account> deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext ctx) { List<Account> vals = new ArrayList<Account>(); for (Map.Entry<String, JsonElement> entry : json.getAsJsonObject().entrySet()) { Account account = ctx.deserialize(entry.getValue(), Account.class); account.setName(entry.getKey()); vals.add(account); } return vals; } }
Action class : static Account[] account=new Account[1]; static String[] arrayofStrings={"1","2","4"}; { Account a=new Account(); a.setName(arrayofStrings); account[0]=a; } //..getters and setters , execute() public String[] getArrayofStrings() { return this.account[0].getName();//Just like yours }
main ... { askUser: "Show List?" / "Show Accountdata" readFromInput -> "yes" displayData(); } dispayData() { try (FileReader fri = new FileReader(yourFile)) { List<Account> accounts = new ArrayList<Account>(); // read file String line; while ((line =fri.readLine()) != null) { Account acc = new Account(); acc.setName(line); // add account number and balance } Collections.sort(accounts); // now in order by accountNumber. for(Account next : accounts) { System.out.println("Number: " + next.accountNumber + " Name: " + next.name); } } }
Account acnt = new Account(); public void actionPerformed(ActionEvent e) { Object source = e.getSource(); if(source == button) { } if(e.getSource() == button) { if(c.isSelected()) { acnt.setId(accID.getText()); acnt.setName(accName.getText()); acnt.setBalance(acnt.getBalance()+Integer.parseInt(amount.getText())); //store.add(ad); area.append("\nDP-"+ acnt.toString()); store.add(acnt); } if(d.isSelected()) { acnt.setId(accID.getText()); acnt.setName(accName.getText()); acnt.setBalance(acnt.getBalance()-Integer.parseInt(amount.getText())); area.append("\nWD-"+acnt.toString()); store.add(acnt); } } }
account.setName(name); account.setAccountNumber(accountNumber); account.setSort(sortCode);
account.setName(name);