项目救急啊 
需求有String str[] =new String[list.size];存放的是sql的查询条件
比如是String str={a,b,c,d,e};要求的比较条件是 a=b and a=c and a=d and a=e 
             and b=c and b=d and b=e
             and c=d and c=e
             and d=e
这只是其中一种条件,因为数组里面的内容是动态的,有高手希望不惜赐教啊,给写个动态生成的代码 小弟在这里感谢大家了。   

解决方案 »

  1.   

    要求的比较条件是 a=b and a=c and a=d and a=e 
      and b=c and b=d and b=e
      and c=d and c=e
      and d=e
      你这个条件 这样写  a=b and a=c and a=d and a=e 这样就能判断他们都相等了吧?还有就是 你的条件 在list里面放着,怎么还重新放到数组里呢?在list里面不行吗?
      

  2.   

    要求的比较条件是 a=b and a=c and a=d and a=e 
      and b=c and b=d and b=e
      and c=d and c=e
      and d=e这个不就是
    a=b=c=d=e吗?
      

  3.   


    public String getWhereCondition(String[] conditions){
    String result = "":
    int arrLenth = conditions.length
    for(int i = 0; i < arrLenth ; i++){
    for(int j = i + 1; j < arrLenth ;j++){
    if(!result.equals("")) result += " and ";
    result += (conditions[i] + " = " + conditions[j]);
    }
    }
    return result;
    }
    看看满足需求不?
      

  4.   

    有a=b and a=c and a=d and a=e  
    就可以知道
    and b=c and b=d and b=e
      and c=d and c=e
      and d=e
    你要做的就是遍历数组,把条件用and拼出 a=b and a=c and a=d and a=e  。 
      

  5.   

    调用list循环比较,或者就a=b=c=d=e..