Hallo ,
Es wird bei der Ausgabe
0 true
1 false
2 true
3 false ausgegeben
Was ich nicht verstehe warum true und false ausgegeben werden?
Java:
public class Start {
boolean zustand = false;
public static void main(String[] args) {
Start obj = new Start();
for( int i = 0; i<= 3; i++)
{
if(obj.getZustand()== true)
{
System.out.println(""+i+ " true");
}
else
{
System.out.println(""+i+ " false");
}
}
}
public boolean getZustand()
{
zustand = (zustand == false);
return zustand;
}
}
Es wird bei der Ausgabe
0 true
1 false
2 true
3 false ausgegeben
Was ich nicht verstehe warum true und false ausgegeben werden?