Assert Different Instance - Java java.lang

Java examples for java.lang:Assert

Description

Assert Different Instance

Demo Code


//package com.java2s;

public class Main {
    public static void main(String[] argv) throws Exception {
        Object o1 = "java2s.com";
        Object o2 = "java2s.com";
        assertDifferentInstance(o1, o2);
    }//w w w  . j  a v a  2  s . c  om

    public static void assertDifferentInstance(final Object o1,
            final Object o2) {
        if (o1 == o2) {
            throw new AssertionError(
                    "The compared objects are the same instance of a class");
        }
    }
}

Related Tutorials