Bonjour,

J'apprend le Java et j'ai un soucis qui pour moi est ... illogique

Voici mon code:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
 
public static List<Account> getAllAccounts(){
	List<Element> accs =  App.conf.LireNoeud("app\\accounts\\account",true);
	List<Account> accounts = new ArrayList<Account>();
 
	if(accs.size()>0){
		System.out.println("Test getAllAccount() :");
		for(int cpt=0; cpt<accs.size(); cpt++){
			int id = Integer.parseInt(accs.get(cpt).getAttributeValue("id"));
			String name = accs.get(cpt).getChildText("name");
			String login = accs.get(cpt).getChildText("login");
			String pwd = accs.get(cpt).getChildText("pwd");
			Account account = new Account(id,name,login,pwd);
			System.out.println("\t" + account.toString());
			accounts.add(account);
			System.out.println("\t" + accounts.get(0).toString());
		}
	}
 
	return accounts;
}
 
@Override
public String toString(){
	String result = "";
	result += "ID : " + this.getID() + "\n";
	result += "\tNom : " + this.getName() + "\n";
	result += "\tLogin : " + this.getLogin() + "\n";
 
	return result;
}
Et voici ce qu'écrit le programme :

Test getAllAccount() :
ID : 1
Nom : test1
Login : adresse1@fd.fr

ID : 1
Nom : test1
Login : adresse1@fd.fr

ID : 2
Nom : test2
Login : adresse2@dce.fr

ID : 1
Nom : test1
Login : adresse2@dce.fr

Merci d'avance pour votre aide