diff -r 000000000000 -r b577ee7fcf67 samples/conditionaluseofapi/src/conditionaluseofapi/StringBuilderAdd15.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/samples/conditionaluseofapi/src/conditionaluseofapi/StringBuilderAdd15.java Sat Jun 14 09:50:50 2008 +0200 @@ -0,0 +1,26 @@ +package conditionaluseofapi; + +/** Implementation for string concatention using Java 5 only. + * + * StringBuilder is supposed to be faster than StringBuffer as it + * is not synchronized and as such it is does not waste time with + * synchronization when its methods are called. + * + * @author Jaroslav Tulach + */ +final class StringBuilderAdd15 implements AddString { + + private StringBuilder sb = new StringBuilder(); + + public void addString(String msg) { + sb.append(msg); + } + + public String getMessage() { + return sb.toString(); + } + + public String toString() { + return "New Shiny and Fast Java 5 Implementation"; + } +}