我在分配数组列表中的值时遇到一些困难。我的代码是:将结果添加到数组列表
while (answer.hasMore()) {
SearchResult rslt = (SearchResult)answer.next();
Attributes attrs = rslt.getAttributes();
System.out.println();
if (attrs.get("department") != null && attrs.get("telephonenumber") != null) {
System.out.println(attrs.get("department") + " " + attrs.get("name") + " " +
attrs.get("Description") + " " + attrs.get("mail") + " " +
attrs.get("telephonenumber")+
attrs.get("samaccountname") + attrs.get("samaccountname"));
}
我想每一个attrs.get("department") + attrs.get("description")+ attrs.get("name")+attrs.get("mail")
的值赋给一个数组列表。
我想在开始时就确定:
String[] name = new String[100];
,并在while循环我试图读取name属性,我试图做的:
name = attrs.get("name");
但没有奏效。任何人都可以帮忙
通过做的工作,你的意思是编译失败?我怀疑'attrs.get()'返回一个'String'? – hmjd 2012-02-22 21:05:38
'attrs.get(“name”);'返回一个字符串?您不能将字符串分配给字符串数组。你可能想要编辑你的问题来表明你真的想要做什么,因为将不同的属性分配给同一个数组真的没什么意义。 – Perception 2012-02-22 21:05:42