Set对象取值的小问题,在线等.
现有一个类News含有 Set<Newd> newd, 如下
public class News {
private Integer id;
private String title;
private String content;
private Set<Newd> newd;
public Set<Newd> getNewd() {
return newd;
}
public void setNewd(Set<Newd> newd) {
this.newd = newd;
}
public void setId(Integer id) {
this.id=id;
}
public Integer getId() {
return this.id;
}
public void setTitle(String title) {
this.title=title;
}
public String getTitle()
{
return this.title;
}
public void setContent(String content) {
this.content=content;
}
public String getContent() {
return this.content;
}
}
另一个Newd类
public class Newd {
private int id;
private News news;
public News getNews() {
return news;
}
public void setNews(News news) {
this.news = news;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getNid() {
return nid;
}
public void setNid(int nid) {
this.nid = nid;
}
private String name;
private int nid;
}
现在测试页面中
...
....
while(it.hasNext()) {
News e = it.next();
System.out.println("ID:"+e.getNewd());
/*
此处可得到Newd对象,只是我再用e.getNewd().getId();就得不到内容,现问,我如果取到Newd对象中的属性值 呢
*/
}
大家认真帮我看下,多谢