== operator
String sr2 = new String(str1); if(str1 == str2){ // str2 and str2 are two separate Strings references, will never print print("True, str1 and str2 point to the same reference") } else { print("False, str1 and str2 point to separate references") // Output }
val str2 = String(str1.toCharArray) if(str1 == str2) { // this will be the output, because == is equivalent to str1.equals(str2) print("str1 and str2 both have the value "Hello") } else { print("str1 and str2 have different values") } === operator - In Kotlin, the '===' operator is equivalent to Java's '==' operator and tests to see if the reference is equal Comments are closed.
|
AuthorExploring Android and mobile web design, security, and development. Archives
March 2021
Categories |