Package com.zybooks.dsaj.analysis
Class StringExperiment
java.lang.Object
com.zybooks.dsaj.analysis.StringExperiment
Provides an empirical test of the efficiency of repeated string concatentation
versus use of the StringBuilder class.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic void
Tests the two versions of the 'repeat' algorithm, doubling the size of n each trial, beginning with the given start value.static String
repeat1
(char c, int n) Uses repeated concatenation to compose a String with n copies of character c.static String
repeat2
(char c, int n) Uses StringBuilder to compose a String with n copies of character c.
-
Constructor Details
-
StringExperiment
public StringExperiment()
-
-
Method Details
-
repeat1
Uses repeated concatenation to compose a String with n copies of character c. -
repeat2
Uses StringBuilder to compose a String with n copies of character c. -
main
Tests the two versions of the 'repeat' algorithm, doubling the size of n each trial, beginning with the given start value. The first command line argument can be used to change the number of trials, and the second to adjust the start value.
-