public class StrPlus {
public static void main(String[] args) {
long start = System.currentTimeMillis();
usePlus(100000, "a");
long end = System.currentTimeMillis();
System.out.println((end - start) + " ms");
}
private static void usePlus(int roopCount, String word) {
String resultStr = "";
for (int count= 0; count < roopCount; count++) {
resultStr = resultStr + word;
}
}
}
public class StrPlus {
public static void main(String[] args) {
long start = System.currentTimeMillis();
usePlus(100000, "a");
long end = System.currentTimeMillis();
System.out.println((end - start) + " ms");
}
private static void usePlus(int roopCount, String word) {
String resultStr = "";
for (int count= 0; count < roopCount; count++) {
resultStr = resultStr + word;
}
}
}
(正確には9000回ぴったりではないです)
public class StrPlus {
public static void main(String[] args) {
int roopCount = 100000;
String word = "a";
usePlus(10000, word);
long start = System.currentTimeMillis();
usePlus(roopCount, word);
long end = System.currentTimeMillis();
System.out.println((end - start) + " ms");
}
private static void usePlus(int roopCount, String word) {
String resultStr = "";
for (int count= 0; count < roopCount; count++) {
resultStr = resultStr + word;
}
}
}
つかってみてね。
これだけ書かれてもよく分からないと思うので・・・