void (String[] args) { Main m = new Main(); if (m.getSameObject() == m.getSameObject()) { System.out.println("This will get printed"); } if (m.getNewObject() == m.getNewObject()) { System.out.println("This will not get printed"); } if (Main.getNewObject() == Main.getNewObject()) { System.out.println("This will not get printed"); } }