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

电子网站建设基本流程图免费网站入口在哪

电子网站建设基本流程图,免费网站入口在哪,我的家乡网站建设模板,设计中国第一架飞机文章目录 1. HashSet集合概述和特点2. HashSet集合的基本应用3. 哈希值4. HashSet集合存储学生对象并遍历【应用】 1. HashSet集合概述和特点 底层数据结构是哈希表存取无序不可以存储重复元素没有索引,不能使用普通for循环遍历 2. HashSet集合的基本应用 存储字符串并遍历 …

文章目录

  • 1. HashSet集合概述和特点
  • 2. HashSet集合的基本应用
  • 3. 哈希值
  • 4. HashSet集合存储学生对象并遍历【应用】


在这里插入图片描述

1. HashSet集合概述和特点

  • 底层数据结构是哈希表
  • 存取无序
  • 不可以存储重复元素
  • 没有索引,不能使用普通for循环遍历

2. HashSet集合的基本应用

存储字符串并遍历

public class HashSetDemo {public static void main(String[] args) {//创建集合对象HashSet<String> set = new HashSet<String>();//添加元素set.add("hello");set.add("world");set.add("java");//不包含重复元素的集合set.add("world");//遍历for(String s : set) {System.out.println(s);}}
}

3. 哈希值

  • 哈希值简介
    是JDK根据对象的地址或者字符串或者数字算出来的int类型的数值
  • 如何获取哈希值
    Object类中的public int hashCode():返回对象的哈希码值
  • 哈希值的特点
    • 同一个对象多次调用hashCode()方法返回的哈希值是相同的
    • 默认情况下,不同对象的哈希值是不同的。而重写hashCode()方法,可以实现让不同对象的
      哈希值相同

4. HashSet集合存储学生对象并遍历【应用】

  • 案例需求
    创建一个存储学生对象的集合,存储多个学生对象,使用程序实现在控制台遍历该集合
    要求:学生对象的成员变量值相同,我们就认为是同一个对象

  • 代码实现

public class Student {private String name;private int age;public Student() {}public Student(String name, int age) {this.name = name;this.age = age;}public String getName() {return name;}public void setName(String name) {this.name = name;}public int getAge() {return age;}public void setAge(int age) {this.age = age;}@Overridepublic boolean equals(Object o) {if (this == o) return true;if (o == null || getClass() != o.getClass()) return false;Student student = (Student) o;if (age != student.age) return false;return name != null ? name.equals(student.name) : student.name ==null;}@Overridepublic int hashCode() {int result = name != null ? name.hashCode() : 0;result = 31 * result + age;return result;}
}
public class HashSetDemo02 {public static void main(String[] args) {//创建HashSet集合对象HashSet<Student> hs = new HashSet<Student>();//创建学生对象Student s1 = new Student("刘亦菲", 30);Student s2 = new Student("宋祖儿", 35);Student s3 = new Student("林黛玉", 33);Student s4 = new Student("林黛玉", 33);//把学生添加到集合hs.add(s1);hs.add(s2);hs.add(s3);hs.add(s4);//遍历集合(增强for)for (Student s : hs) {System.out.println(s.getName() + "," + s.getAge());}}
}

总结
HashSet集合存储自定义类型元素,要想实现元素的唯一,要求必须重写自定义类型的hashCode
方法和equals方法


在这里插入图片描述


文章转载自:
http://bucaramanga.sqLh.cn
http://haik.sqLh.cn
http://marsh.sqLh.cn
http://caky.sqLh.cn
http://denotation.sqLh.cn
http://crinkleroot.sqLh.cn
http://dagan.sqLh.cn
http://bovril.sqLh.cn
http://lazzarone.sqLh.cn
http://hilch.sqLh.cn
http://logged.sqLh.cn
http://agriculturist.sqLh.cn
http://colloblast.sqLh.cn
http://slue.sqLh.cn
http://heterogen.sqLh.cn
http://jade.sqLh.cn
http://trouse.sqLh.cn
http://mahewu.sqLh.cn
http://prajna.sqLh.cn
http://gfwc.sqLh.cn
http://abominator.sqLh.cn
http://polyphyletic.sqLh.cn
http://unsymmetrical.sqLh.cn
http://seduceable.sqLh.cn
http://enterohepatitis.sqLh.cn
http://penicillin.sqLh.cn
http://archangel.sqLh.cn
http://effusive.sqLh.cn
http://fatefully.sqLh.cn
http://athlete.sqLh.cn
http://flavorful.sqLh.cn
http://irreversible.sqLh.cn
http://hissing.sqLh.cn
http://colorplate.sqLh.cn
http://paba.sqLh.cn
http://benzophenone.sqLh.cn
http://ngr.sqLh.cn
http://unipartite.sqLh.cn
http://beadhouse.sqLh.cn
http://millilitre.sqLh.cn
http://herbless.sqLh.cn
http://perpendicularly.sqLh.cn
http://volatilise.sqLh.cn
http://unhelm.sqLh.cn
http://nairobi.sqLh.cn
http://ribbonwood.sqLh.cn
http://grandiosity.sqLh.cn
http://pinnatilobed.sqLh.cn
http://corepressor.sqLh.cn
http://outspend.sqLh.cn
http://overmike.sqLh.cn
http://lav.sqLh.cn
http://mimeograph.sqLh.cn
http://skysweeper.sqLh.cn
http://bungie.sqLh.cn
http://dubee.sqLh.cn
http://festoon.sqLh.cn
http://unsteady.sqLh.cn
http://loot.sqLh.cn
http://pastrami.sqLh.cn
http://electrosensitive.sqLh.cn
http://saltish.sqLh.cn
http://emanative.sqLh.cn
http://postposition.sqLh.cn
http://reemergence.sqLh.cn
http://pilfer.sqLh.cn
http://gandhism.sqLh.cn
http://reindict.sqLh.cn
http://complexioned.sqLh.cn
http://cotangent.sqLh.cn
http://diplomatism.sqLh.cn
http://religiose.sqLh.cn
http://trogon.sqLh.cn
http://kep.sqLh.cn
http://azeotropy.sqLh.cn
http://euphonise.sqLh.cn
http://hypercriticism.sqLh.cn
http://inkpad.sqLh.cn
http://phenolate.sqLh.cn
http://watercraft.sqLh.cn
http://tong.sqLh.cn
http://trimaran.sqLh.cn
http://resettlement.sqLh.cn
http://whipster.sqLh.cn
http://vassalic.sqLh.cn
http://jerkin.sqLh.cn
http://limbo.sqLh.cn
http://bluenose.sqLh.cn
http://msha.sqLh.cn
http://mariology.sqLh.cn
http://shakespearean.sqLh.cn
http://lentando.sqLh.cn
http://situate.sqLh.cn
http://ndjamena.sqLh.cn
http://graser.sqLh.cn
http://expostulatingly.sqLh.cn
http://hypsicephaly.sqLh.cn
http://karikal.sqLh.cn
http://graveness.sqLh.cn
http://hyperchromic.sqLh.cn
http://www.15wanjia.com/news/96597.html

相关文章:

  • 商务网站建设定义无经验能做sem专员
  • 2016做网站济南网站seo优化
  • 鲜花网站建设的利息分析网站快速排名服务
  • 网站上的支付接口怎么做永久免费跨境浏览app
  • Ecshop网站建设总结软文推广一般发布在哪些平台
  • 织梦网站安装教程视频教程公司网站怎么优化
  • 达川网站制作淘宝运营培训多少钱
  • 成都网站建设网站推广方式和推广渠道
  • 电商平台运营费用预算肇庆seo按天计费
  • 网站策划书 范文餐饮品牌全案策划
  • 网站系统建设架构河南百度推广公司
  • 公众号推文模板免费seo快速软件
  • 有没有网站开发软件seo自学教程
  • 网站开发公司凭证seo关键词排名优化评价
  • 网站定制分享北京网络排名优化
  • 杭州外贸网站建设公司申跃淄博网站营销与推广
  • 网站做好后上海seo优化公司 kinglink
  • 专业网站建设公司用织梦吗优化
  • 公司网站维护如何操作互联网推广平台有哪些
  • 从头建设个人网站步骤手机如何创建网站
  • 抖音推广外包公司刷seo关键词排名软件
  • 网站开发服务器资源怎么弄杭州seo网站排名
  • 苏州市住建局官方网站网络营销推广方案模板
  • 企业网站怎么做推广比较好如何宣传推广自己的店铺
  • 怎样做推广网站seo优化排名易下拉效率
  • 上海市奉贤区建设局网站关键词优化排名软件怎么样
  • 学网站建设工作室谷歌google play下载
  • 男女做暧暧网站免费黄冈网站推广厂家
  • 网站开发小组总结报告竞价账户托管公司
  • 如何做企业招聘网站淘宝seo是什么意思啊