+ 1

Can someone describe me, what is the output snd how this code works? Thanks Pls German but English is ok also.

int x = 7; int p = 0; while (p < 3) { System.out.print (x); } thanks for help :)

7th Mar 2017, 6:38 PM
nwytg
4 Antworten
+ 11
This is an infinite loop and it will print 7 forever, because p is always less than 3. Variable p is not incremented. Das ist eine Schleife, die endlos läuft und immer 7 ausgibt, weil p immer kleiner als 3 bleibt. Die Variable p wird nicht hochgezählt.
7th Mar 2017, 6:50 PM
Tashi N
Tashi N - avatar
+ 2
Thanks, Danke!
7th Mar 2017, 6:53 PM
nwytg
+ 1
It was really helpful :). I like this Q&A I learned here really much!
7th Mar 2017, 6:54 PM
nwytg
0
Hi! The output is 7777... So it is an infinite loop, until var p is less than 3.
7th Mar 2017, 6:48 PM
Maxim Yarovoy
Maxim Yarovoy - avatar