Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Need help with StringBuffer
Index -> Programming, Java -> Java Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
vicml21




PostPosted: 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
Sponsor
Sponsor
Sponsor
sponsor
Display posts from previous:   
   Index -> Programming, Java -> Java Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 1 Posts ]
Jump to:   


Style:  
Search: