Cześć. Mam pytanie. Co dokładnie robi ta pętla tutaj?
public void addingString()
{
String str = "a";
long startTime = System.currentTimeMillis();
for(int i = 0; i<100000; i++)
{
str = str + "a";
}
long endTime = System.currentTimeMillis();
long result = endTime-startTime;
System.out.println(result);
}
Rozumiem, że samo currentTimeMilis() sprawdza ile czasu trwał cały proces, ale na jaką choinkę jest tutaj "str=str+"a"?
Samo str=str by nie wystarczyło żeby obliczyć ten czas? Czy to nie ma żadnego znaczenia a to ciało pętli jest czysto hipotetyczne?