Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static void main(String[] args) {
- int iterations = 10000;
- long start = System.currentTimeMillis();
- String text = "";
- for (int count = 0; count < iterations; count++) {
- text += "Test" + "\n";
- }
- System.out.println("+ took: " + Long.toString(System.currentTimeMillis() - start) + "ms");
- start = System.currentTimeMillis();
- StringBuilder builder = new StringBuilder();
- for (int count = 0; count < iterations; count++) {
- builder.append("Test").append("\n");
- }
- System.out.println("StringBuilder took: " + Long.toString(System.currentTimeMillis() - start) + "ms");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement