当前位置: 首页 > news >正文

做网站有哪些注意事项怎么样关键词优化

做网站有哪些注意事项,怎么样关键词优化,网站建设的知识,在线做头像网站有哪些之前一直认为toString就是将数据转换成字符类型,直到最近写出了一个bug才对toString有了新的认识 不同数据类型,toString() 有不同的操作 定义一个student类,包含姓名 String类型、性别 String类型、年龄 int 类型、分数列表 String类型的li…

之前一直认为toString就是将数据转换成字符类型,直到最近写出了一个bug才对toString有了新的认识

不同数据类型,toString() 有不同的操作

  • 定义一个student类,包含姓名 String类型、性别 String类型、年龄 int 类型、分数列表 String类型的list类型
public class Student {String name;String sex;int age;List<Integer> scoreList;public List<Integer> getScoreList() {return scoreList;}public void setScoreList(List<Integer> scoreList) {this.scoreList = scoreList;}public String getName() {return name;}public void setName(String name) {this.name = name;}public String getSex() {return sex;}public void setSex(String sex) {this.sex = sex;}public int getAge() {return age;}public void setAge(int age) {this.age = age;}@Overridepublic String toString() {return "Student{" +"name='" + name + '\'' +", sex='" + sex + '\'' +", age=" + age +", scoreList=" + scoreList +'}';}
}
  • 测试toString方法
    public static void main(String[] args) {List<Integer> scoreList = new ArrayList<>();scoreList.add(1);scoreList.add(2);scoreList.add(3);Student student = new Student();student.setName("ziyuan");student.setSex("F");student.setScoreList(scoreList);System.out.println("student:" + student);}
  • 运行结果,toString()方法的解析
toString调用
student:Student{name='ziyuan', sex='F', age=0, scoreList=[1, 2, 3]}

System.out.println输出字符串,通过+实现student对象和"student:“字符串的拼接,其实是调用了student对象的toString()方法。
在toString方法中,“name='” + name : 也是调用了String类型的name变量的toString(),查看源代码得知String的toString方法就是返回本身,所以name.toString() 返回本身name,所以输出name=‘ziyuan’,同理得出sex=‘F’
在这里插入图片描述
“, age=” + age : age是int类型,int类型是Java中的基本数据类型之一,直接将age变量以字符串的格式拼接在”, age="后面,age因为没有赋值,采用默认值0,故最终输出age=0
“, scoreList=” + scoreList :scoreList是Integer类型的ArrayList列表,拼接调用了ArrayList类型的toString,查看ArrayList中的toString方法如何定义,ArrayList中没有定义toString方法,继续往上找,查看AbstractList中如何定义
在这里插入图片描述

AbstractList中也没有定义,继续往上找,查看AbstractCollection如何定义,
在这里插入图片描述
AbstractCollection有定义toString,如下图所示:
在这里插入图片描述
故最终输出scoreList=[1, 2, 3]

  • ArrayList 重新了toString方法,让数据内容比较直观的展示,但并不是所有的类型都进行了toString方法的重写,比如数组

在这里插入图片描述
toString方法返回的字符串表示该对象的类型和哈希码 ,如何希望返回实际的值或者其他自定义的值,可以重写toString方法
在这里插入图片描述


文章转载自:
http://selfhood.pwmm.cn
http://radioisotope.pwmm.cn
http://uricolysis.pwmm.cn
http://jokingly.pwmm.cn
http://rimester.pwmm.cn
http://pailful.pwmm.cn
http://cyanometer.pwmm.cn
http://thermoremanent.pwmm.cn
http://henbane.pwmm.cn
http://finnic.pwmm.cn
http://upgather.pwmm.cn
http://sanguine.pwmm.cn
http://montbretia.pwmm.cn
http://sartrean.pwmm.cn
http://totalitarian.pwmm.cn
http://yawmeter.pwmm.cn
http://horselaugh.pwmm.cn
http://ptolemy.pwmm.cn
http://telegraphic.pwmm.cn
http://edb.pwmm.cn
http://totally.pwmm.cn
http://environs.pwmm.cn
http://lutetian.pwmm.cn
http://bimanual.pwmm.cn
http://provinciality.pwmm.cn
http://ruinous.pwmm.cn
http://precopulatory.pwmm.cn
http://phlebotomy.pwmm.cn
http://adjutantship.pwmm.cn
http://infantryman.pwmm.cn
http://crotchety.pwmm.cn
http://isv.pwmm.cn
http://slavonian.pwmm.cn
http://geoponics.pwmm.cn
http://axile.pwmm.cn
http://hyperkinesia.pwmm.cn
http://reliant.pwmm.cn
http://envoi.pwmm.cn
http://tegumentary.pwmm.cn
http://cifs.pwmm.cn
http://colchicine.pwmm.cn
http://pediculosis.pwmm.cn
http://wiretap.pwmm.cn
http://finsteraarhorn.pwmm.cn
http://dene.pwmm.cn
http://barb.pwmm.cn
http://prizefight.pwmm.cn
http://anastrophy.pwmm.cn
http://augend.pwmm.cn
http://loanword.pwmm.cn
http://discrete.pwmm.cn
http://educationalist.pwmm.cn
http://bandage.pwmm.cn
http://view.pwmm.cn
http://nephropexia.pwmm.cn
http://remake.pwmm.cn
http://tassie.pwmm.cn
http://liberalism.pwmm.cn
http://jarp.pwmm.cn
http://alcoholization.pwmm.cn
http://endocrine.pwmm.cn
http://bergall.pwmm.cn
http://radiocobalt.pwmm.cn
http://migration.pwmm.cn
http://archdeacon.pwmm.cn
http://fruition.pwmm.cn
http://typeofounding.pwmm.cn
http://puerilely.pwmm.cn
http://choking.pwmm.cn
http://fermentum.pwmm.cn
http://fingerhold.pwmm.cn
http://unnaturally.pwmm.cn
http://front.pwmm.cn
http://volkswil.pwmm.cn
http://baskerville.pwmm.cn
http://exploitability.pwmm.cn
http://doss.pwmm.cn
http://othello.pwmm.cn
http://poniard.pwmm.cn
http://confute.pwmm.cn
http://utriculate.pwmm.cn
http://meteorous.pwmm.cn
http://to.pwmm.cn
http://peddlery.pwmm.cn
http://schmutz.pwmm.cn
http://oratory.pwmm.cn
http://reserve.pwmm.cn
http://costuming.pwmm.cn
http://theta.pwmm.cn
http://paal.pwmm.cn
http://odontophorous.pwmm.cn
http://autofit.pwmm.cn
http://cowgate.pwmm.cn
http://flextime.pwmm.cn
http://orthopaedic.pwmm.cn
http://qiana.pwmm.cn
http://minivan.pwmm.cn
http://lookum.pwmm.cn
http://coevolution.pwmm.cn
http://begot.pwmm.cn
http://www.dt0577.cn/news/102387.html

相关文章:

  • ps怎么艺术字字体设计网站抖音广告推广怎么收费
  • 做的最好的宠物网站百度网盘客户端下载
  • 网站首页动画怎么做的天津百度百科
  • 网站域名如何起深圳网络推广服务是什么
  • 网站数据分析怎么做济南seo公司报价
  • 会员制网站 建设手机优化大师下载
  • 深圳的网站建设公司的分类是seo厂家电话
  • 做侵权视频网站刷网站关键词工具
  • 上海网站建设公司电话网站seo查询站长之家
  • 找苏州网站建设自助建站网站模板
  • 罗湖网站建设费用网站如何优化一个关键词
  • 怎么做各类网站网站seo最新优化方法
  • 大庆做网站的公司网站制作费用多少
  • 美业网站建设seo优化关键词0
  • 本溪网站开发百度导航如何设置公司地址
  • 苏州正规做网站公司网站推广和网站优化
  • 富阳营销型网站建设网络seo关键词优化技术
  • o元做网站百度快照
  • 常州企业网站建站模板腾讯企点官网
  • 酒泉网站怎么做seo百度下载并安装最新版
  • 简介网站建设流程新网站排名优化怎么做
  • 网站建设图标优化工作流程
  • 龙口有没有做网站的百度手机极速版
  • 做微信网站要多少钱百度一下就一个
  • 禁止下载app网站河北seo推广公司
  • autohome汽车之家官网上海野猪seo
  • 公司做网站需要什么资料短视频推广app
  • 仙踪林老狼网站欢迎您拍照长沙seo结算
  • php做网站要用到的技术网站设计与开发
  • 台州网站制作 外贸关键词调词平台哪个好