hashset存储对象,以及如何对相同对象不进行储存
package haxi;
import java.util.HashSet;
public class Hashset {
public static void main(String[] args) {
// TODO 自动生成的方法存根
HashSet
Student student1 = new Student("yyz", 18);
Student student2 = new Student("yyzz", 18);
Student student3 = new Student("yyzzz", 18);
Student student4 = new Student("yyz", 18);
s1.add(student1);
s1.add(student2);
s1.add(student3);
for (Student string : s1) {
Student s2 = string;
S
共有 0 条评论