why '==' operator is not used to compare two strings in java.
what is the difference between equals() method and '==' operator while comparing two string? Here is the piece of code
public class Solution {
public int numDistinct(String A, String B) {
int ans =0;
if(A==B)
ans = 1;
return ans;
}
}
but ans is 0, why?