+ 1
Guys, is this the right way of nesting an if else statement in Kotlin coz my code is outputting an error
This is it fun main(args:Array<String>){ var n1=3 var n2=5 var n3=-2 val max=if(n1>n3) if(n1>n3) n1 else n3 }else{ if(n2>n3) n3 else n3 } println ("max=$max") }
1 Réponse
+ 4
I don't think you can make it with a declaration of "val max =..."
And your second if statement is the same as your first.
If(n1>n3)
If(n2>n1)
n2
Else
N1
Else if(n2>n3)
N2
Else
N3
Is that what you're trying to do?