SomeObject obj = new SomeObject(); SomeObject sameObj = obj; Assert.assertSame(obj, sameObj); // Passes
SomeObject obj1 = new SomeObject(); SomeObject obj2 = new SomeObject(); Assert.assertSame(obj1, obj2); // Fails
ListThe `assertSame()` method belongs to the `junit.framework.Assert` package.objList = new ArrayList<>(); SomeObject obj = new SomeObject(); objList.add(obj); Assert.assertSame(obj, objList.get(0)); // Passes