æ¬å½ã«ããè¸ãè¿ããã話ã ã¨æãã
æ¬é¡ã¨ããããã©ãã¤ãã§ã«è¨åãã¦ãããããã¨ãããã®ã§æ¸ãã¦ããã
å人çã«ã¯ null ãå³è¾ºã®å ´å㯠false ãè¿ãã®ã«ã左辺ã«ããå ´åã«ãã«ããæãã¦ãã¾ãã¨ããé対称æ§ãæ°æã¡æªããããä½ã¨ããããã¨ããæ°æã¡ããããã¤ããªã¡ã½ãããç¨æãããã¨ãçæ³ã ã¨æã£ã¦ããã®ã ãã©ãå®éã«ä½¿ãã¨ãªãã¨ããã¯ããã§é¢åããããã ãããªã
èªå㯠"foo".equals(s) æ´¾ã§ããã®çç±ã¯ãã¯ããã«ããæããããããã£ã¨ãããããã§ããã*1
å®ã¯å ãã¿ (ãããã ココ ããå§ã¾ã£ã¦ããã¨æããããã³ã¡ã³ãããã³ä¸é£ã®ãã©ãã¯ããã¯) ãããããã¨èªãã§ãããã¡ã«ãs 㨠"foo" ã£ã¦ãã©ã£ã¡ãåãç«å ´ãããªãï¼ããããããèªåã®ä¸ã§ã¯ç¬¬ä¸è ã s 㨠"foo" ãæ¯ã¹ãã¤ã¡ã¼ã¸ã ãã strcmp ç㪠(å¼æ°ã®é åºãæå³ãæããªã) è¨è¿°ã®æ¹ãç´è¦³çã§ã¯ï¼ãã£ã¦ã®ãæãã¦ãã¦ãString ã¯ã©ã¹ã« static ãªã¡ã½ãã equals(String, String) ãããã°ã
åè§ãä»é¶´ã丸ãæ²»ã¾ãããããªããã¨æã£ã¦ããããä¸è¨ã®è¨äºãçºè¦ãã次第ã
equals ã®ããã«èªåã¨åãåã®ãªãã¸ã§ã¯ããå¼æ°ã«ã¨ãã¡ã½ããããã¤ããªã¡ã½ããã¨å¼ã¶ã®ã¯ç¥ããªãã£ããããåå¼·ã«ãªã£ãã
*1:ãã®å½æã®èªåã¯ãããæ£è§£ã ã¨æã£ã¦ãã