Welches Programm braucht weniger Zeit oder Platz?
1) Variable h ist „global``:
int s = 0; int h;
for (int i = 0; i<n; i++) {
h = i*i; s += h;
}
2) Variable h ist lokal:
int s = 0;
for (int i = 0; i<n; i++) {
int h = i*i; s += h;
}
Antwort: keines, javac erzeugt identischen Bytecode.