题目内容
(7-1)根据提示补全程序空白处,使程序能够正确运行。classBook{privateStringname;privatedoubleprice;//重写Object中的hashCode()方法@Overridepublic①hashCode(){finalintprime=31;intresult=1;result=prime*result+((name==null)?0:name.hashCode());longtemp;temp=Double.doubleToLongBits(price);result=prime*result+(int)(temp^(temp>>>32));returnresult;}//重写Object的equals()方法@Overridepublic②equals(③arg){if(④)//如果obj与当前对象的引用相同returntrue;if(arg==null)returnfalse;if(getClass()!=arg.getClass())returnfalse;Bookother=(Book)arg;if(name==null){if(other.name!=null)returnfalse;}elseif(⑤)//如果name不同returnfalse;if(Double.doubleToLongBits(price)!=Double.doubleToLongBits(other.price))returnfalse;returntrue;}}
查看答案
搜索结果不匹配?点我反馈