黑龙江省城乡和住房建设厅网站首页简述seo和sem的区别与联系

张小明 2026/1/19 19:16:58
黑龙江省城乡和住房建设厅网站首页,简述seo和sem的区别与联系,wordpress建站图片效果,网上商店是指https://www.jb51.net/program/330116r71.htm 问题场景 子类StudentResp继承父类PersonResp#xff0c;子类也拥有了父类的属性。 给子类中继承的父类属性的赋值#xff0c;但是打印了以后只会显示子类信息#xff0c;父类信息不显示。 子类#xff1a;学生类继承父类人…https://www.jb51.net/program/330116r71.htm问题场景子类StudentResp继承父类PersonResp子类也拥有了父类的属性。给子类中继承的父类属性的赋值但是打印了以后只会显示子类信息父类信息不显示。子类学生类继承父类人员类12345678910111213DatapublicclassStudentRespextendsPersonResp {/*** 学号*/privateInteger studentId;/*** 成绩*/privateInteger score;}父类人员类12345678910111213DatapublicclassPersonResp {/*** 姓名*/privateString name;/*** 年龄*/privateInteger age;}代码中给子类以及继承的父类信息赋值然后打印12345678910111213publicstaticvoidmain (String[] args) {StudentResp studentResp newStudentResp();//学生子类赋值studentResp.setStudentId(1000000000);studentResp.setScore(92);//父类赋值studentResp.setName(风清扬);studentResp.setAge(18);//打印学生子类信息System.out.println(studentResp);}打印出来只有子类自己的属性父类的属性没有出来问题分析单独获取子类中父类的信息name跟age观察打印看有没有值1234567891011121314publicstaticvoidmain (String[] args) {StudentResp studentResp newStudentResp();//学生子类赋值studentResp.setStudentId(1000000000);studentResp.setScore(92);//父类赋值studentResp.setName(风清扬);studentResp.setAge(18);//打印父类信息System.out.println(姓名 studentResp.getName());System.out.println(年龄 studentResp.getAge());}打印出来发现是有值的确认了继承本身是没有问题的继承的父类的值都可以给上也能获取到随后直接打开target对应目录下的StudentResp子类观察编译后的代码12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576publicclassStudentRespextendsPersonResp {privateInteger studentId;privateInteger score;publicStudentResp() {}publicInteger getStudentId() {returnthis.studentId;}publicInteger getScore() {returnthis.score;}publicvoidsetStudentId(finalInteger studentId) {this.studentId studentId;}publicvoidsetScore(finalInteger score) {this.score score;}publicbooleanequals(finalObject o) {if(o this) {returntrue;}elseif(!(oinstanceofStudentResp)) {returnfalse;}else{StudentResp other (StudentResp)o;if(!other.canEqual(this)) {returnfalse;}else{Objectthis$studentId this.getStudentId();Object other$studentId other.getStudentId();if(this$studentId null) {if(other$studentId !null) {returnfalse;}}elseif(!this$studentId.equals(other$studentId)) {returnfalse;}Objectthis$score this.getScore();Object other$score other.getScore();if(this$score null) {if(other$score !null) {returnfalse;}}elseif(!this$score.equals(other$score)) {returnfalse;}returntrue;}}}protectedbooleancanEqual(finalObject other) {returnotherinstanceofStudentResp;}publicinthashCode() {intPRIME true;intresult 1;Object $studentId this.getStudentId();intresult result *59 ($studentId null?43: $studentId.hashCode());Object $score this.getScore();result result *59 ($score null?43: $score.hashCode());returnresult;}publicString toString() {returnStudentResp(studentIdthis.getStudentId() , scorethis.getScore() );}}看到这里大多数同学应该已经定位到出现问题的原因了。最后的toString()方法可以明确的看到这里只取了子类本身的两个属性并没有去获取父类的属性。问题原因通过看编译后的代码可以得出Data不会打印继承的父类信息是因为该注解本身作用域的问题Data注解在编译时会自动给实体类添加SetterGetterToString等方法。但是Data注解的作用域只在当前类中所以最终打印的时候只会打印出当前类子类的信息。即使子类拥有的是全属性但是打印不会显示父类信息。解决方式本文介绍两种解决方案。第一种在子类上添加ToString(callSuper true)注解该注解会将父类的属性跟子类的属性一起生成toString第二种不使用Data注解使用SetterGetter注解在父类中重写toString()方法并用JSON的方式打印。1.子类添加ToString(callSuper true)注解1234567891011121314DataToString(callSuper true)publicclassStudentRespextendsPersonResp {/*** 学号*/privateInteger studentId;/*** 成绩*/privateInteger score;}打印子类12345678910111213publicstaticvoidmain (String[] args) {StudentResp studentResp newStudentResp();//学生子类赋值studentResp.setStudentId(1000000000);studentResp.setScore(92);//父类赋值studentResp.setName(风清扬);studentResp.setAge(18);//学生子类System.out.println(studentResp);}结果可以看到父类信息再看看target中子类编译后的代码12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576publicclassStudentRespextendsPersonResp {privateInteger studentId;privateInteger score;publicStudentResp() {}publicInteger getStudentId() {returnthis.studentId;}publicInteger getScore() {returnthis.score;}publicvoidsetStudentId(finalInteger studentId) {this.studentId studentId;}publicvoidsetScore(finalInteger score) {this.score score;}publicbooleanequals(finalObject o) {if(o this) {returntrue;}elseif(!(oinstanceofStudentResp)) {returnfalse;}else{StudentResp other (StudentResp)o;if(!other.canEqual(this)) {returnfalse;}else{Objectthis$studentId this.getStudentId();Object other$studentId other.getStudentId();if(this$studentId null) {if(other$studentId !null) {returnfalse;}}elseif(!this$studentId.equals(other$studentId)) {returnfalse;}Objectthis$score this.getScore();Object other$score other.getScore();if(this$score null) {if(other$score !null) {returnfalse;}}elseif(!this$score.equals(other$score)) {returnfalse;}returntrue;}}}protectedbooleancanEqual(finalObject other) {returnotherinstanceofStudentResp;}publicinthashCode() {intPRIME true;intresult 1;Object $studentId this.getStudentId();intresult result *59 ($studentId null?43: $studentId.hashCode());Object $score this.getScore();result result *59 ($score null?43: $score.hashCode());returnresult;}publicString toString() {returnStudentResp(supersuper.toString() , studentIdthis.getStudentId() , scorethis.getScore() );}}可以明确的看到最后的toString()方法中多了一个super.toString()方法将父类的信息打印出来2.不使用Data注解使用SetterGetter注解在父类中重写toString()方法并用JSON的方式打印。子类使用SetterGetter注解1234567891011121314GetterSetterpublicclassStudentRespextendsPersonResp {/*** 学号*/privateInteger studentId;/*** 成绩*/privateInteger score;}父类中重写toString()方法并用JSON的方式打印1234567891011121314151617181920DatapublicclassPersonResp {/*** 姓名*/privateString name;/*** 年龄*/privateInteger age;OverridepublicString toString() {returnJSON.toJSONString(this);}}打印子类12345678910111213publicstaticvoidmain (String[] args) {StudentResp studentResp newStudentResp();//学生子类赋值studentResp.setStudentId(1000000000);studentResp.setScore(92);//父类赋值studentResp.setName(风清扬);studentResp.setAge(18);//学生子类System.out.println(studentResp);}结果也可以看到父类信息总结这个问题本身不算是个大问题延伸出来更为重要的是我们解决问题的思路。因为从本质上来说属性本身都是存在的只是没打印出来。但是遇到这个问题的时候第一反应都是明明继承了父类为啥父类的值会没有从而会带偏我们去解决问题方向遇到此类问题第一我们应该先确认问题的本质到底有没有给上值确认了已经给上值就说明只是打印的问题进而去编译后的代码中查看为啥没打印出来最终定位到问题从而解决问题。
版权声明:本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若内容造成侵权/违法违规/事实不符,请联系邮箱:809451989@qq.com进行投诉反馈,一经查实,立即删除!

台州市建设招标投标网站饭店装修设计

还在为网易云音乐的NCM加密格式而烦恼吗?当你发现精心收藏的音乐无法在其他设备上播放时,那种失落感我们深有体会。ncmdumpGUI作为一款专业的音乐解锁工具,专门解决NCM解密和音频格式转换的难题,让你真正拥有自己购买的音乐。 【免…

张小明 2026/1/17 20:11:41 网站建设

网站制作青岛公司长沙seo工作室

第一章:AI Agent部署概述随着人工智能技术的快速发展,AI Agent 已广泛应用于自动化运维、智能客服、数据分析等场景。部署 AI Agent 不仅涉及模型本身的运行环境配置,还需考虑服务化封装、资源调度、安全策略和持续监控等多个维度。核心组件与…

张小明 2026/1/17 20:11:42 网站建设

张家港网站设计制作早晨设计企业网站建设基本流程

终极跨平台书签同步指南:BookmarkHub免费完整解决方案 【免费下载链接】BookmarkHub BookmarkHub , sync bookmarks across different browsers 项目地址: https://gitcode.com/gh_mirrors/bo/BookmarkHub 你是否曾在办公室Chrome浏览器收藏的重要资料&#…

张小明 2026/1/17 20:11:42 网站建设

腾讯网站的品牌建设计划网站ftp用户名和密码

查壳无壳,64位 ALTT搜索main,CTRLT寻找main函数,发现爆红,典型jmp“原地打转”的短跳转 移到jmp上,右键,如此nop掉 发现nop不完,越nop越nop多,可猜测是下面那串长数据被有规律地插入…

张小明 2026/1/17 20:11:43 网站建设

深圳网站设计公司怎么找平邑网站定制

模块概述80111-60470是一款工业级动态集成模块,设计用于实时监控、数据采集和控制系统。它通过高度集成的硬件和软件接口,将多种功能组合到单一模块中,简化系统架构,提高效率和可靠性。主要功能实时数据采集与处理支持高速模拟量和…

张小明 2026/1/17 20:11:45 网站建设