how to compare the string which is passed as a parameter
the following method is not working.
String str = "saveMe"
compareString(str)
def compareString(String str){
def str2 = "saveMe"
if(str2==${str}){
println "same"
}else{
println "not same"
}
}
also tried
String str = "India"
compareString(str)
def compareString(String str){
def str2 = "india"
if( str2 == str ) {
println "same"
}else{
println "not same"
}
}
This should be an answer
str2.equals( str )
If you want to ignore case
str2.equalsIgnoreCase( str )