Download Set_advanced_project/Set_module/src/HashSet_package/LinkedHashSet_demo.java from zxy0307/Java: direct link, hf CLI and curl.
- Browser
- Download file 768 Bytes
-
https://huggingface.co/zxy0307/Java/resolve/main/Set_advanced_project/Set_module/src/HashSet_package/LinkedHashSet_demo.java
- Command line
-
hf download hf://zxy0307/Java/Set_advanced_project/Set_module/src/HashSet_package/LinkedHashSet_demo.java
-
curl -L -o LinkedHashSet_demo.java https://huggingface.co/zxy0307/Java/resolve/main/Set_advanced_project/Set_module/src/HashSet_package/LinkedHashSet_demo.java
768 Bytes
| package HashSet_package; | |
| import java.util.LinkedHashSet; | |
| public class LinkedHashSet_demo { | |
| public static void main(String[] args) { | |
| //1、创建三个学生对象 | |
| Student s1 = new Student("zhangsan", 23); | |
| Student s2 = new Student("lisi", 24); | |
| Student s3 = new Student("wangwu", 25); | |
| Student s4 = new Student("zhangsan", 23); | |
| //2、创建集合用来添加学生 | |
| LinkedHashSet<Student> lhs = new LinkedHashSet<>(); | |
| //3、添加元素 | |
| System.out.println(lhs.add(s1)); | |
| System.out.println(lhs.add(s2)); | |
| System.out.println(lhs.add(s3)); | |
| System.out.println(lhs.add(s4)); | |
| //4、打印集合,反映添加的先后顺序 | |
| System.out.println(lhs); | |
| } | |
| } | |