Code Correctness: Erroneous String Compare

 

Abstract

Strings should be compared with the equals() method, not == or !=.

Description

This program uses == or != to compare two strings for equality, which compares two objects for equality, not their values. Chances are good that the two references will never be equal.

Examples

The following branch will never be taken.

	  if (args[0] == STRING_CONSTANT) {
		  logger.info("miracle");
	  }