I am trying to update a TextArea with a userList whenever a client enters as an admin. However the first client has only his name and the second has his name with the first client. What I want is to be able to update the list for the first client. For example, if a third client joined in, it should update the list for the first and second clients.
Here is my webservice method
public String getuserList ()
{
String usname = "";
synchronized(username)
{
for (int i = 0; i < username.size(); i++)
{
usname = usname + "\n" + username.get(i);
}
return usname;
}
}
any suggestions?
Thanks.
From an API design standpoint, I would expect a
getUserListto return aListthan a String. For all other purposes, your implementation looks just OK.You may consider using
StringBuilderto build the final string than the+operator.EDIT : to show an example scenario.