Ad
  • Custom User Avatar

    Good point. StringBuilder is the way to go. 10 months ago I didn't even know about SB :P

  • Default User Avatar

    .length points to just a field of array object. No calculations are even beeing performed at this point.
    The much worse is concatenating strings in a cycle. That's a very bad practice

  • Custom User Avatar

    You make unnecessary calls to friends.length. This is never going to change throught the execution of this method, so to optimize your code you should define it as a variable in the beginning. You are basically making a function call to friends.length each iteration of the for loop as well as when defining your "ret" array. Just a heads up!