import ballerina/io;

class MyClass {
    int i = 0;
}

public function main() {
    MyClass obj1 = new MyClass();
    MyClass obj2 = new MyClass();
    // `b1` will be true.
    boolean b1 = (obj1 === obj1);

    io:println(b1);

    // `b2` will be false.
    boolean b2 = (obj1 === obj2);

    io:println(b2);

    // `b3` will be true.
    boolean b3 = ([1, 2, 3] == [1, 2, 3]);

    io:println(b3);

    // `b4` will be false.
    boolean b4 = ([1, 2, 3] === [1, 2, 3]);

    io:println(b4);

    // `b5` will be true.
    boolean b5 = (-0.0 == +0.0);

    io:println(b5);

    // `b6` will be false.
    boolean b6 = (-0.0 === +0.0);

    io:println(b6);

}

Identity

=== and !== operators test for identity. Values of mutable basic types are identical if and only if they are stored in the same address. == and != are not defined for objects. -0.0 and +0.0 are equal but not identical.

import ballerina/io;
class MyClass {
    int i = 0;
}
public function main() {
    MyClass obj1 = new MyClass();
    MyClass obj2 = new MyClass();
    boolean b1 = (obj1 === obj1);

b1 will be true.

    io:println(b1);
    boolean b2 = (obj1 === obj2);

b2 will be false.

    io:println(b2);
    boolean b3 = ([1, 2, 3] == [1, 2, 3]);

b3 will be true.

    io:println(b3);
    boolean b4 = ([1, 2, 3] === [1, 2, 3]);

b4 will be false.

    io:println(b4);
    boolean b5 = (-0.0 == +0.0);

b5 will be true.

    io:println(b5);
    boolean b6 = (-0.0 === +0.0);

b6 will be false.

    io:println(b6);
}
bal run identity.bal
true
false
true
false
true
false