Hello guys. I was wondering if you could use a thing in python in java. That is an elif statement. It is saying else if. It will execute a block of code if the condition in the if statement is false and the condition in the elif statement is true. So can you do this?
elif
Collapse
X
-
Tags: None
-
That's just a shorthand used in languages like Python because of the way they define blocks and statements. In Java you just write the code:Originally posted by Kid ProgrammerHello guys. I was wondering if you could use a thing in python in java. That is an elif statement. It is saying else if. It will execute a block of code if the condition in the if statement is false and the condition in the elif statement is true. So can you do this?
[CODE=Java]
if (condition1) {
} else if (condition2) {
} else {
}[/CODE]
In VB, for example, this would be:
[CODE=VB]If Condition1 Then
ElseIf Condition2 Then
Else
End If[/CODE]
Note: the ElseIf guarantees that only one End If is required. -
Thanks I understand :-)Originally posted by BigDaddyLHThat's just a shorthand used in languages like Python because of the way they define blocks and statements. In Java you just write the code:
[CODE=Java]
if (condition1) {
} else if (condition2) {
} else {
}[/CODE]
In VB, for example, this would be:
[CODE=VB]If Condition1 Then
ElseIf Condition2 Then
Else
End If[/CODE]
Note: the ElseIf guarantees that only one End If is required.Comment
Comment