Hello,
Wie würde das in etwa aussehen, wenn ich auf eine public-instanzvariable direkt zugreife bzw. ihn ändern will?
public class MyStaticClass {
// wichtig: darf nicht "final" deklariert sein, sonst ist Änderung nicht möglich
public static myCounter = 0;
}
public class MyMainClass {
public static void main(String[] args) {
for (int i = 0; i < 100; i++) {
// erhöhe den Counter um 1
MyStaticClass.myCounter++;
}
// gib den Counter aus
System.out.println(MyStaticClass.myCounter);
}
}
MfG
Rouven
--
-------------------
sh:| fo:} ch:? rl:( br:& n4:{ ie:| mo:} va:) js:| de:] zu:| fl:( ss:) ls:& (SelfCode)
Friendships are like back yard gardens. We always mean to tend to them, we just seem to put to put them off until next week. -- Christian Clemenson as Jerry Espenson in Boston Legal: "Patriot Acts"
-------------------
sh:| fo:} ch:? rl:( br:& n4:{ ie:| mo:} va:) js:| de:] zu:| fl:( ss:) ls:& (SelfCode)
Friendships are like back yard gardens. We always mean to tend to them, we just seem to put to put them off until next week. -- Christian Clemenson as Jerry Espenson in Boston Legal: "Patriot Acts"