Loading...

CPE 103-00Statement of ObjectiveIn his book Effective Java,Joshua Bloch warns against using the String concatenation operator forrepeated string concatentations. For once-only use like n("Result:"+total+"years"); result=result+"word"; Bloch recommends using Java's StringBuilder class as a much fasteralternative.

The purpose of this experiment is to see if String concatenation isreally as bad as Bloch says it is, and if so, to determine ifStringBuilder is really any better. TheoryBloch explains that since String is immutable, it can't simply append"word" to result, but that it has to make a copy of both operands thencombine them and create a new string to hold the result.

The copyoperation is very expensive; he asserts that it is a quadratic time operation.

Soin theory we should expect to see the performance of StringBuilder ismuch faster than String Electrical & Computer Engineering Program, School of Engineering and Computer Science in Waco, Texas, is a private Baptist university, and a nationally ranked liberal arts institution. ECE Lab. Lab Reports - Explains formatting requirements for ECE laboratory reports. Sample Formal Report Xilinx ISE - Getting Started..

Description of Experimental SetupThe experiments were performed on a desktop workstation with 3 GB RAMand a Dual Core Processor running at 2. ProcedureWe wrote a small program that implements both techniques.

Onemethod, concat(), uses a loop to repeat a String concatentationoperation a given number of times A new laboratory course in computer science for liberal arts students has been analyze the results and write a brief laboratory report which must be turned in at Most students are surprised by the outcome of this experiment since they find .

A second method, concatFast()uses StringBuilder. We wrote a main method that calls them insidea loop that provides an increasing limit for the number ofconcatentations, so several experimental trials can be runautomatically.

The core of the concat() method builds a string using the concatenationoperator "+=".

The concatFast() on the other hand, usesStringBuilder's append() method Suggestions for clear lab reports in computer science courses (Your documentation should make clear what the code does at a high level, not how it does it at .

We chose an arbitrary length of 80characters for the string to be appended.