packageTest.set;importorg.junit.jupiter.api.Test;importjava.util.HashSet;importjava.util.Iterator;importjava.util.LinkedHashSet;importjava.util.Set;/*** List: 有序可重复 有序指的是下标有序 可重复指的是不同下标位置上可以存储相同值的元素* Set: 无序不可重复 录入的顺序和存储的顺序不一致 不可重复指的是相同值的元素不可重复存储*/publicclassLinkedHashSetTest{@Testpublicvoidtest01(){Set set =newHashSet();byte a =1;short b =2;int c =3;long d =4L;double e =5.0d;float f =6.0f;char g ='a';boolean h =false;set.add(a);set.add(b);set.add(c);set.add(d);set.add(e);set.add(f);set.add(g);set.add(h);set.add(a);System.out.println(set);}//[6.0, 1, a, 2, 3, 4, 5.0, false]@Testpublicvoidtest02(){Set set =newLinkedHashSet();byte a =1;short b =2;int c =3;long d =4L;double e =5.0d;float f =6.0f;char g ='a';boolean h =false;set.add(a);set.add(b);set.add(c);set.add(d);set.add(e);set.add(f);set.add(g);set.add(h);set.add(a);System.out.println(set);}//[1, 2, 3, 4, 5.0, 6.0, a, false]@Testpublicvoidtest03(){Set set =newLinkedHashSet();set.add(2);set.add(1);set.add(1);System.out.println(set);}//[2, 1]@Testpublicvoidtest04(){Set<String> set =newLinkedHashSet<>();for(int i =0; i <5; i++){set.add("xm"+(i +1));}System.out.println(set);for(String name : set){System.out.println(name);}}/*
[xm1, xm2, xm3, xm4, xm5]
xm1
xm2
xm3
xm4
xm5*/@Testpublicvoidtest05(){Set<String> set =newLinkedHashSet<>();for(int i =0; i <5; i++){set.add("xm"+(i +1));}System.out.println(set);Iterator<String> it = set.iterator();while(it.hasNext()){String name = it.next();System.out.println(name);}}/*
[xm1, xm2, xm3, xm4, xm5]
xm1
xm2
xm3
xm4
xm5*/}
HashSetTest
packageTest.set;importorg.junit.jupiter.api.Test;importjava.util.*;/*** List: 有序可重复 有序指的是下标有序 可重复指的是不同下标位置上可以存储相同值的元素* Set: 无序不可重复 录入的顺序和存储的顺序不一致 不可重复指的是相同值的元素不可重复存储*/publicclassHashSetTest{@Testpublicvoidtest01(){List list =newArrayList();byte a =1;short b =2;int c =3;long d =4L;double e =5.0d;float f =6.0f;char g ='a';boolean h =false;list.add(a);list.add(b);list.add(c);list.add(d);list.add(e);list.add(f);list.add(g);list.add(h);list.add(a);System.out.println(list);}//[1, 2, 3, 4, 5.0, 6.0, a, false, 1]@Testpublicvoidtest02(){Set set =newHashSet();byte a =1;short b =2;int c =3;long d =4L;double e =5.0d;float f =6.0f;char g ='a';boolean h =false;set.add(a);set.add(b);set.add(c);set.add(d);set.add(e);set.add(f);set.add(g);set.add(h);set.add(a);System.out.println(set);}//[6.0, 1, a, 2, 3, 4, 5.0, false]@Testpublicvoidtest03(){Set set =newHashSet();set.add(2);set.add(1);set.add(1);System.out.println(set);}//[1, 2]@Testpublicvoidtest04(){Set<String> set =newHashSet<>();for(int i =0; i <5; i++){set.add("xm"+(i +1));}System.out.println(set);for(String name : set){System.out.println(name);}}/*
[xm5, xm2, xm1, xm4, xm3]
xm5
xm2
xm1
xm4
xm3*/@Testpublicvoidtest05(){Set<String> set =newHashSet<>();for(int i =0; i <5; i++){set.add("xm"+(i +1));}System.out.println(set);Iterator<String> it = set.iterator();while(it.hasNext()){String name = it.next();System.out.println(name);}}/*
[xm5, xm2, xm1, xm4, xm3]
xm5
xm2
xm1
xm4
xm3*/}
Error in lm.fit(x, y, offset = offset, singular.ok = singular.ok, ...): singular fit encountered 目录
Error in lm.fit(x, y, offset = offset, singular.ok = singular.ok, ...): singular fit encountered
类似的错误