private List<String> getCjList(){
String cj1 = manufacturer1.getText();
String cj2 = manufacturer2.getText();
String cj3 = manufacturer3.getText();
String cj4 = manufacturer4.getText();
String cj5 = manufacturer5.getText();
String cj6 = manufacturer6.getText();
String cj7 = manufacturer7.getText();
String cj8 = manufacturer8.getText();
String cj9 = manufacturer9.getText();
String cj10 = manufacturer10.getText();
List<String> cjList = new ArrayList<String>();
int i = 1;
while(i > 0 && i < 11){
String cj = "cj";
if(!(cj + i).equals("")){
cjList.add(cj + i);
log.debug("++++++++++++++++++++++++++++++++++++++++=cj " + (cj + i) );
}
i++;
}
return cjList;
}
我想把变量cj1到cj10中不为空的存入cjList,可是存入的确是字符串“cj1”到 “cj10”。请哪位兄台指点一二。
String cj1 = manufacturer1.getText();
String cj2 = manufacturer2.getText();
String cj3 = manufacturer3.getText();
String cj4 = manufacturer4.getText();
String cj5 = manufacturer5.getText();
String cj6 = manufacturer6.getText();
String cj7 = manufacturer7.getText();
String cj8 = manufacturer8.getText();
String cj9 = manufacturer9.getText();
String cj10 = manufacturer10.getText();
List<String> cjList = new ArrayList<String>();
int i = 1;
while(i > 0 && i < 11){
String cj = "cj";
if(!(cj + i).equals("")){
cjList.add(cj + i);
log.debug("++++++++++++++++++++++++++++++++++++++++=cj " + (cj + i) );
}
i++;
}
return cjList;
}
我想把变量cj1到cj10中不为空的存入cjList,可是存入的确是字符串“cj1”到 “cj10”。请哪位兄台指点一二。
解决方案 »
- 关于反射中的getModifiers()方法返回值不包含包访问权限修饰符的问题
- myeclipse8.5 更换了工作空间不响应
- jtable显示ResultSet记录集速度问题
- struts异常处理的问题,key是干什么的?
- 一个关于向文本中写数据的问题
- 请教高手一个JAVA显示图形的问题!!!!!!!!!!!!!!!!!!!!!
- 处理字符串的一个问题.急...
- 请教高手,关于logic:iterate中取链接值的问题?
- 急需JAVA写的显示饼状图、柱状图的程序。
- eclipse运行错误,求大神帮忙。
- 哪位大哥有从把数据从数据库导入到压缩文件的JAVA例子呀?谢谢?
- 在线等待:JDOM解析XML文件的问题
private List<String> getCjList(){
String cj1 = manufacturer1.getText();
String cj2 = manufacturer2.getText();
String cj3 = manufacturer3.getText();
String cj4 = manufacturer4.getText();
String cj5 = manufacturer5.getText();
String cj6 = manufacturer6.getText();
String cj7 = manufacturer7.getText();
String cj8 = manufacturer8.getText();
String cj9 = manufacturer9.getText();
String cj10 = manufacturer10.getText();
List<String> cjList = new ArrayList<String>();
int i = 1;
while(i > 0 && i < 11){
String cj = "cj";
if(!(cj + i).equals("")){
cjList.add(cj + i);
log.debug("++++++++++++++++++++++++++++++++++++++++=cj " + (cj + i) );
}
i++;
}
return cjList;
}
while(i > 0 && i < 11){
String cj = "cj";
if(!cjArray[i].quals("")){
cjList.add(cj + i);
log.debug("++++++++++++++++++++++++++++++++++++++++=cj " + (cj + i) );
}
i++;
}
List<String> cjList = new ArrayList<String>();
if(null!=manufacturer1.getText()&&!"".equals(manufacturer1.getText())){
cjList.add(manufacturer1.getText());
}
while(i > 0 && i < 11){
String cj = "cj";
if(!(cj + i).equals("")){
cjList.add(cj + i);
log.debug("++++++++++++++++++++++++++++++++++++++++=cj " + (cj + i) );
}
i++;
}
能不能在在if的条件里面因为i的不同去取不同的变量?