class EqualsEquals  
{
	public static void main (String[] args) 
	{
		String strA;  // reference to the first object
		String strB;  // reference to the second object
   
		// create the first object and save its reference
		strA = new String("same characters"); 
		System.out.println(strA); 

		// create the second object and save its reference
		strB = new String("same characters");   
		System.out.println(strB);

		if (strA == strB) 
		System.out.println("This will not print.");
	}
}

Back to Lesson 10 Examples

Back to Java Main Page