- 1
Can i use else loop as optional ? Is it correct or wrong?
7 Antworten
+ 2
Your question is unclear what do u mean by else loop as optional rewrite it again
+ 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
{
}
+ 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;
}
0
What is else loop?
0
The else loop in the if loop..but we not provide condition on else loop but if loop we can provide condition
0
Your question is not clear again write in hindi Urdu or any other languages which u know better
0
Else part is optional ?