Java Function Analysis

Posted by khan on Stack Overflow See other posts from Stack Overflow or by khan
Published on 2012-10-04T09:02:08Z Indexed on 2012/10/04 9:37 UTC
Read the original article Hit count: 204

Filed under:
|

Okay..I am a total Python guy and have very rarely worked with Java and its methods. The condition is that I have a got a Java function that I have to explain to my instructor and I have got no clue about how to do so..so if one of you can read this properly, kindly help me out in breaking it down and explaining it. Also, i need to find out any flaw in its operation (i.e. usage of loops, etc.) if there is any. Finally, what is the difference between 'string' and 'string[]' types?

public static void search(String findfrom, String[] thething){
  if(thething.length > 5){
      System.err.println("The thing is quite long");
  }

  else{
      int[] rescount = new int[thething.length];
      for(int i = 0; i < thething.length; i++){
          String[] characs = findfrom.split("[ \"\'\t\n\b\f\r]", 0);
          for(int j = 0; j < characs.length; j++){
              if(characs[j].compareTo(thething[i]) == 0){
                  rescount[i]++;
        }
    }
      }
      for (int j = 0; j < thething.length; j++) {
          System.out.println(thething[j] + ": " + rescount[j]);
      }
  }
}

© Stack Overflow or respective owner

Related posts about java

Related posts about for-loop