0
0

More than 1 year has passed since last update.

instanceが同一か確認。equals method

Posted at

newした2つのinstanceを比較する

Sample.java
public class Sample {
    int i;
}
    public static void main(String[] args) {
        Sample s1 = new Sample();
        Sample s2 = new Sample();
        System.out.println(s1.equals(s2));
        s1 = s2;
        System.out.println(s1.equals(s2));
    }
false
true
0
0
3

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0