Computer Science Canada

Need help with StringBuffer

Author:  vicml21 [ Thu Nov 24, 2005 11:30 pm ]
Post subject:  Need help with StringBuffer

code:
public class Lab10Exc2
{
    // reverse a string
    public static StringBuffer reverse (String src)
    {
        StringBuffer str = new StringBuffer ();
        for (int k = (src.length () - 1) ; k >= 0 ; k--)
        {
            str.append (src.charAt (k));
        }
        return str;
    }


    public static void main (String argv[])
    {
        StringBuffer message = "Today is a sunny day!";
        StringBuffer reversed = reverse (message);
        System.out.println ("The reverse of: " + message + " is: " + reversed);
    }
}


ok im not really sure how StringBuffers work, but what this program is supposed to do is get the text "Today is a sunny day!" and reverse it using StringBuffers & for loops


: