Last active
December 24, 2015 06:49
-
-
Save nickserv/6759236 to your computer and use it in GitHub Desktop.
Java: StringBuilder Example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.lang.StringBuilder; | |
public class StringBuilderExample { | |
public static void main(String args[]) { | |
String s = ""; | |
s += "I have "; | |
s += 50; | |
s += " cats."; | |
System.out.println(s); | |
StringBuilder sb = new StringBuilder(); | |
sb.append("I have "); | |
sb.append(50); | |
sb.append(" cats."); | |
System.out.println(sb); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment