直接上代码吧,好理解
package com.norelax.www.factory;
/**
* 新闻实体类
*
* @author wusong
* @create 2017-05-29 上午10:29
**/
public class News {
String title;
String content;
public News(String title, String content) {
this.title = title;
this.content = content;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public String getContent() {
return content;
}
public void setContent(String content) {
this.content = content;
}
@Override
public String toString() {
return "News{" +
"title='" + title + '\'' +
", content='" + content + '\'' +
'}';
}
}
静态工厂方法实体类:
<