1ãinstanceofæ¯Javaçä¸ä¸ªäºå
æä½ç¬¦ï¼å==ï¼>ï¼<æ¯åä¸ç±»ä¸ä¸ãç±äºå®æ¯ç±åæ¯ç»æçï¼æ以ä¹æ¯Javaçä¿çå
³é®åãå®çä½ç¨æ¯æµè¯å®å·¦è¾¹ç对象æ¯å¦æ¯å®å³è¾¹çç±»çå®ä¾ï¼è¿åbooleanç±»åçæ°æ®ã举个ä¾åï¼
ããString s = "I AM an Object!";
ããboolean isObject = s instanceof Object;
ããæ们声æäºä¸ä¸ªString对象å¼ç¨ï¼æåä¸ä¸ªString对象ï¼ç¶åç¨instancofæ¥æµè¯å®ææåç对象æ¯å¦æ¯Objectç±»çä¸ä¸ªå®ä¾ï¼æ¾ç¶ï¼è¿æ¯ççï¼æ以è¿åtrueï¼ä¹å°±æ¯isObjectçå¼ä¸ºTrueã
2ãå¦ä¸ç§æ¹å¼æ¯ä½¿ç¨ getClass()å¤æ
æ¯å¦ï¼if(s.getClass()==String.getClass())
温馨提示:内容为网友见解,仅供参考