如何尽可能优化这个函数?
public void r1(String st1, int[] ar1) {
    String inox = "newsearch";
    for (int j = 0; j < ar1.length; j++) {
        if (st1.equals(inox) && ar1[j] * 2 > 20) {
            Integer intx = new Integer(ar1[j]);
            intx = intx * 2;
            System.out.print(intx.toString());
        }
    }
}发布于 2012-09-26 23:30:18
这是一个相当奇怪的代码,但它与。
public void r1(String st1, int[] ar1) {
    if (!str1.equals("newsearch")) return;
    for (int j : ar1) {
        int j2 = j * 2;
        if (j2 > 20) 
            System.out.print(j2);
    }
}发布于 2012-09-26 23:30:09
public void r1(String st1, int[] ar1) {
    String inox = "newsearch";
    if (st1.equals(inox) {
        for (int j = 0; j < ar1.length; j++) {
             if (ar1[j] > 10) {
                System.out.print(ar1[j] * 2);
            }
        }
    }
}发布于 2012-09-26 23:32:14
public void r1(String st1, int[] ar1) {
  if (st1.equals("newsearch") {
    for (int j = 0; j < ar1.length; j++) {
      if (ar1[j] > 10) {
        System.out.print(ar1[j] * 2);
      }
    }
  }
}https://stackoverflow.com/questions/12605202
复制相似问题