Here you can find the source of equals(String str1, String str2)
Parameter | Description |
---|---|
str1 | first string to compare, can be null |
str2 | second string to compare, can be null |
public static boolean equals(String str1, String str2)
//package com.java2s; //License from project: Open Source License public class Main { /**/*from ww w . ja v a 2s .c o m*/ * Comparing two strings, returns true if they are equal, if both are null -> result == true * * @param str1 * first string to compare, can be null * @param str2 * second string to compare, can be null * @return true if string are equal or if both of references are null, compare is case sensitive */ public static boolean equals(String str1, String str2) { if (str1 == null) { return str2 == null; } return str1.equals(str2); } }