- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStringBuilders.java
More file actions
Latest commit
26 lines (22 loc) · 871 Bytes
/
Copy pathStringBuilders.java
File metadata and controls
26 lines (22 loc) · 871 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
publicclassStringBuilders {
publicstaticvoidmain(String[] args) {
//Menos performatico.
longtempoInicial = System.currentTimeMillis();
Stringalpha = "a";
for (charcurrent = 'b'; current <= 'z';current ++){
alpha += current;
}
System.out.println(alpha);
longtempoFinal = System.currentTimeMillis();
System.out.printf("%.3f ms%n", (tempoFinal - tempoInicial) / 1000d);
//Mais performatico.
longtempoInicial1 = System.currentTimeMillis();
StringBuildersb = newStringBuilder();
for (charcurrent = 'a'; current <= 'z'; current++){
sb.append(current);
}
System.out.println(sb);
longtempoFinal1 = System.currentTimeMillis();
System.out.printf("%.3f ms%n", (tempoFinal1 - tempoInicial1) / 1000d);
}
}