BlackRock Interview Question: Reverse a string in java.... | Glassdoor

Interview Question

Summer Analyst Interview(Student Candidate)

Reverse a string in java.

Answer

Interview Answer

1 Answer

0

Neeraj Kulkarni of Bloomberg Law Ke Ma Ke Chooth

class ReverseString {
  public static String reverseIt(String source) {
    int i, len = source.length();
    StringBuffer dest = new StringBuffer(len);

    for (i = (len - 1); i >= 0; i--)
      dest.append(source.charAt(i));
    return dest.toString();
  }
}

Neeraj Kulkarni Ke Ma Ke Chooth on Jun 8, 2011

Add Answers or Comments

To comment on this, Sign In or Sign Up.