1 |
This class returns object of class String which reverses order of characters in input object source which is also an instance of class String
|
2 |
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();
-
}
-
}
|
3 |
length, CharAt and toString are methods of class String which is used for fixed character strings
|
4 |
StringBuffer is constructor of class StringBuffer which is used for mutable character strings and has methods append and toString
|