Given:
public class Main { String name; //w w w .j av a2s .c o m Main(String s) { name = s; } public static void main(String[] args) { Main d1 = new Main("Boi"); Main d2 = new Main("Tyri"); System.out.print((d1 == d2) + " "); Main d3 = new Main("Boi"); d2 = d1; System.out.print((d1 == d2) + " "); System.out.print((d1 == d3) + " "); } }
What is the result?
C is correct.
The == operator tests for reference variable equality, not object equality.