主题:java里List的问题
小弟java新手,上来就要做个web项目,遇到了问题。那位答人有空帮忙看看代码怎么改,小弟在这里谢谢先了!
public class SearchBean {
private String productName;
private List resultlist;
public String finalresult(){
resultlist=ProductServiceImpl.search(productName);
return "success";
}
}
public class ProductServiceImpl {
public static List<Product> search(String name){
String productname="liyang";
List<Product> productNameList=new LinkedList<Product>();
while(productname.equals(name)){
for(int i=0; i<100; i++){
Product product=new Product();
product.setId(i);
product.setName("leffe");
product.setCountry("belgium");
product.setCategory("beer");
product.setDate(1020);
productNameList=new LinkedList<Product>(); //想把生成的对象加到链表里
}
}
return productNameList;
}
}
public class SearchBean {
private String productName;
private List resultlist;
public String finalresult(){
resultlist=ProductServiceImpl.search(productName);
return "success";
}
}
public class ProductServiceImpl {
public static List<Product> search(String name){
String productname="liyang";
List<Product> productNameList=new LinkedList<Product>();
while(productname.equals(name)){
for(int i=0; i<100; i++){
Product product=new Product();
product.setId(i);
product.setName("leffe");
product.setCountry("belgium");
product.setCategory("beer");
product.setDate(1020);
productNameList=new LinkedList<Product>(); //想把生成的对象加到链表里
}
}
return productNameList;
}
}