Can someone please explain me how does work this construction and tell in which cases I can use it? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Can someone please explain me how does work this construction and tell in which cases I can use it?

while(true) { ... else { break; } }

7th Nov 2019, 12:47 PM
Ksenia Dmitrieva
Ksenia Dmitrieva - avatar
2 Answers
0
Compile error occurs. Because else without if statement doesn't work. It should may be like while(true) { ... If(condition) { break; } .. } Or like while(condition) { ... if(condition) { ... } else { break; } ... } is your looking this code explanation, or correction is enough..
7th Nov 2019, 1:21 PM
Jayakrishna 🇮🇳
0
Ok, if it's works only with "if" i understand how it works, thanks
7th Nov 2019, 1:44 PM
Ksenia Dmitrieva
Ksenia Dmitrieva - avatar