Salesforce

www.salesforce.com

Interview Question

Quality Engineer Interview Seattle, WA

Write a Java function that reverses a string and write unit

  tests for it.
Answer

Interview Answer

1 Answer

0

public String reverse_string(String first) {
String[] result = "";
int size = first.length() - 1;
int initial = 0;

for(int i = size; i >= 0; i--) {
result[initial++] = first.get(i);
}

return result;
}

AG on Aug 26, 2012

Add Answers or Comments

To comment on this, Sign In or Sign Up.