Translate

Tuesday 5 October 2021

Conditional Structure in Groovy Scripting groovy training telugu 31

 Watch This Video

https://youtu.be/-3Pt0lcbPgk


-------------------------------------------------------------------------------------------------------------

// if boolean (expression) {// logic}

if (true){

println true
}

if (true)
println true

def age=35

if (age>=35){
println "can run president"

}


if (false){

println true
}

else {

println false
}

def yourage=18
if(yourage>=21){
println"eligible for Marriage"
}
else{
println "not eligible for Marriage"
}


def someage=37

if(someage>= 21 && someage <35){
println "eligible for Marriage"
}

else if(someage >= 35){

println "run for president"

}
else {
println "not eligible for Marriage"

}

// ternary operator

def name='Dan'
def isitdan=(name.toUpperCase()=='DAN')?'YES":'NO'
println isitdan

//switch

def num=5
switch(num){
case 1:
println "1"

case 2:

println "2"
default:
println "default value"

}

No comments:

Post a Comment

Note: only a member of this blog may post a comment.