CyberArmy University | Open Source Institute | CyberArmy Intelligence & Security | CyberArmy Services & Projects

In this case . . .


[Replies] [Reply] [View by Thread] [Help]
[Back To SNEAK Development Forum]

Posted by Cpt SAJChurchey On 2005-02-26 23:18:34
In Reply to RE: Java - Backwards - Second Draft Posted by Ret. Gen D-Cypell On 2005-02-26 19:22:23

Cpt
Cpt SAJChurchey


The empty string check in this case is negligible, but what about in the other functions where a lot more operations are being performed on the data. I condensed some of the code and called trim() before reverse() was called, in case of input w/ large amounts of leading/trailing whitespace.
public String backwards(String input)
{
   if(input == null)
   {
       throw new IllegalArgumentException("null not supported");
   }//end if
   StringBuffer buffer = new StringBuffer(input.trim());
   return buffer.reverse().toString();
} 
Cpt SAJChurchey
C/O of
Editorial
OSI Staff edit0r
OSI Feedback Representative




Replies:


Guest:
Subject:
Message:
Signature:
Optional Image Link:
http://

CyberArmy::Forum v0.6
Generated In 0.02282 seconds


About Us | Privacy Policy | Mission Statement | Help