- 1

Can i use else loop as optional ? Is it correct or wrong?

2nd Oct 2021, 11:09 AM
Amala Yakin
7 Antworten
+ 2
Your question is unclear what do u mean by else loop as optional rewrite it again
2nd Oct 2021, 11:22 AM
A S Raghuvanshi
A S Raghuvanshi - avatar
+ 2
Amala Yakin you can use loop with if statement and else in both part like this but yeah if u dont want to write else part u can u dont need to write else statement your statement will look like this if(true) { for( init ; cond;++/--){ Do whatever you want } } else // optional if u dont want to write even you can write if statement instead of else you need to write condition { }
2nd Oct 2021, 12:30 PM
A S Raghuvanshi
A S Raghuvanshi - avatar
+ 1
Amala Yakin if and else are not loop, that are known as conditional statement. else part is not necessary for example: public boolean isNecessary() { if (x > 0) { return true; } else { return false; } } You can write it without else also: public boolean isNecessary() { if (x > 0) { return true; } return false; }
2nd Oct 2021, 12:26 PM
A͢J
A͢J - avatar
0
What is else loop?
2nd Oct 2021, 12:18 PM
A͢J
A͢J - avatar
0
The else loop in the if loop..but we not provide condition on else loop but if loop we can provide condition
2nd Oct 2021, 12:24 PM
Amala Yakin
0
Your question is not clear again write in hindi Urdu or any other languages which u know better
2nd Oct 2021, 12:26 PM
A S Raghuvanshi
A S Raghuvanshi - avatar
0
Else part is optional ?
2nd Oct 2021, 12:27 PM
Amala Yakin