中文亚洲精品无码_熟女乱子伦免费_人人超碰人人爱国产_亚洲熟妇女综合网

當(dāng)前位置: 首頁 > news >正文

為什么要用國外服務(wù)器做網(wǎng)站搜索引擎優(yōu)化英文簡稱為

為什么要用國外服務(wù)器做網(wǎng)站,搜索引擎優(yōu)化英文簡稱為,可更新的web 網(wǎng)站開發(fā),項目四網(wǎng)站建設(shè)實訓(xùn)報告集合體系結(jié)構(gòu) Collection 單列集合 包含List Set List 包含ArrayList LinkedList Set包含HashSet TreeSet HashSet包含LinkedHashSet List系列集合:添加的元素是有序的、可重復(fù)、有索引 Set系列集合:添加的元素是無序的、不重復(fù)、無索引 Collectio…

集合體系結(jié)構(gòu)

Collection 單列集合

包含List Set

List 包含ArrayList LinkedList

Set包含HashSet TreeSet

HashSet包含LinkedHashSet

List系列集合:添加的元素是有序的、可重復(fù)、有索引

Set系列集合:添加的元素是無序的、不重復(fù)、無索引

Collection是單列集合的祖宗接口,它的功能是全部單列集合都可以繼承使用的

    public static void main(String[] args) {//Collection是一個接口,我們不能直接創(chuàng)建它的對象Collection<String> coll=new ArrayList<>();//1.添加元素/*細節(jié)1.如果王List里添加元素,方法總是返回true 因為List允許元素重復(fù)細節(jié)2.如果往Set李添加元素,不存在返回true,存在返回falseSet系列集合不允許重復(fù)* */coll.add("aaa");coll.add("bbb");coll.add("ccc");coll.add("ddd");System.out.println(coll);//2.清空
//        coll.clear();
//        System.out.println(coll);//3.刪除//因為Collection里面定義的方法是共性的方法,所以不能通過索引進行刪除,智能通過元素的對象進行刪除/*方法會有一個布爾類型的返回值,true刪除成功,false失敗* */coll.remove("aaa");System.out.println(coll);//4.判斷元素是否包含//底層是依賴equals方法進行判斷是否存在的//所以要判斷自定義對象是否存在時候,要重新equals方法System.out.println(coll.contains("bbb"));//5.判空boolean empty = coll.isEmpty();System.out.println(empty);//6.獲取集合的長度int size = coll.size();System.out.println(size);}

Collection的遍歷方式

迭代器遍歷

特點:迭代器不依賴索引

迭代器在Java中的類是Iterator,迭代器是集合專用的遍歷方式

Collection<Integer> collection= new ArrayList<>();
collection.add(1);
collection.add(2);
collection.add(3);
Iterator<Integer> it=collection.iterator();
while (it.hasNext()){int i=it.next();System.out.print(i+"  ");
}

細節(jié)注意:

1.報錯NoSuchElementException

2.迭代器遍歷完畢,指針不會復(fù)位

3.循環(huán)中只能用一次next方法

4,迭代器遍歷時,不能用集合的方法進行添加或者刪除

增強for遍歷

增強for的底層就是迭代器,為了簡化迭代器的代碼書寫的

所有的單列集合和數(shù)組才能用增強for遍歷

格式:

for(元素的數(shù)據(jù)類型 變量名:數(shù)組或者集合){

}

for(String s : list){

}

public static void main(String[] args) {Collection<String> coll = new ArrayList<>();coll.add("zhangsan");coll.add("lisi");coll.add("wangwu");for (String s : coll) {System.out.println(s);}
}

細節(jié):

修改增強for中的變量,不會改變集合中原來的數(shù)據(jù)

Lambda表達式遍歷

    public static void main(String[] args) {Collection<String> coll = new ArrayList<>();coll.add("zhangsan");coll.add("lisi");coll.add("wangwu");/*      coll.forEach(new Consumer<String>() {@Override//s 是以此表示集合的每一個數(shù)據(jù)public void accept(String s) {System.out.println(s);}});*/coll.forEach(s -> System.out.println(s));}
}

List中常見的方法和遍歷方式

//List集合中的兩個刪除的方法
//1.直接刪除元素
//2.通過素銀進行刪除//1.創(chuàng)建集合并添加元素
//1.創(chuàng)建一個集合
List<String> list =new ArrayList<>();//2.添加元素
list.add("a");
list.add("b");
list.add("c");//void add(int index,E element);在指定索引位置添加指定的元素
//細節(jié):
/*
原來索引上的元素會依次往后移
* */
list.add(1,"QQQ");//remove
String remove = list.remove(0);
System.out.println(remove);//set
String  aaa = list.set(0, "aaa");
System.out.println(aaa);//get
String s = list.get(0);
System.out.println(s);//3.打印集合
System.out.println(list);

List集合的五種遍歷方式

        //創(chuàng)建集合List<String> list = new ArrayList<>();list.add("aaa");list.add("bbb");list.add("ccc");list.add("ddd");list.add("eee");/* //1.迭代器遍歷Iterator<String> iterator = list.iterator();while (iterator.hasNext()){String next = iterator.next();System.out.println(next);}*///2.增強for/*    for (String str : list) {System.out.println(str);}*///3.Lambda表達式
/*        list.forEach(s-> System.out.println(s));*///4.普通for/*      for (int i = 0; i < list.size(); i++) {String s = list.get(i);System.out.println(s);}*///5.列表迭代器//獲取一個列表迭代器對象,同樣的里面的指針也是指向零索引ListIterator<String> it = list.listIterator();while (it.hasNext()){String next = it.next();if ("bbb".equals(next)){it.add("qqq");}System.out.println(next);}System.out.println(list);

遍歷方式比較

迭代器遍歷:在遍歷的過程中需要刪元素,請使用迭代器

列表迭代器:在遍歷的時候需要添加元素,請使用列表迭代器

增強for,Lambda:僅僅想遍歷

普通for:如果遍歷的時候想操作索引

Set系列集合

無序:存取順序不一致

不重復(fù):可以去除重復(fù)

無索引:沒有帶索引的方法,所以不能使用普通for遍歷,也不能通過索引獲取元素

Set集合的實現(xiàn)類

HashSet:無序,不重復(fù),無索引

LinkedHashSet:有序,不重復(fù),無索引

TreeSet:可排序,不重復(fù),無索引

        //1.創(chuàng)建Set集合對象Set<String> s = new HashSet<>();//2.添加元素s.add("aaa");s.add("bbb");s.add("ccc");s.add("ddd");
//        s.add("aaa");3.遍歷//迭代器遍歷Iterator<String> iterator = s.iterator();while (iterator.hasNext()) {String next = iterator.next();System.out.println(next);}//增強forfor (String s1 : s) {System.out.println(s1);}//Lambda表達式s.forEach(a -> System.out.println(a));

HshSet底層采取哈希表存儲數(shù)據(jù)

TreeSet集合默認的規(guī)則:對于字符、字符串類型,按照ASCII碼表中的順序進行排序

TreeSet的兩種排序方式

1.自然排序

類里面實現(xiàn)Comparable接口里面的方法

@Override
public int compareTo(Student o) {//指定排序的規(guī)則//按照年齡的升序進行排序return    this.getAge()-o.getAge();}

2.比較器排序

TreeSet<String> ts = new TreeSet<>((o1, o2) -> {int i = o1.length() - o2.length();i = i == 0 ? o1.compareTo(o2) : i;return i;
});
TreeSet<String> ts = new TreeSet<>(new Comparator<String>() {@Overridepublic int compare(String o1, String o2) {int i = o1.length() - o2.length();i = i == 0 ? o1.compareTo(o2) : i;return i;}
});

使用場景

1.如果想要集合中的元素可重復(fù)

用ArrayList基于數(shù)組的

2.如果想要集合中的元素可重復(fù),而且當(dāng)前的增刪操作明顯多于查詢

用LinkedList,基于鏈表的

3.如果想對集合中的元素去重

用HashSet,基于哈希表的

4.如果想對集合中的元素去重,而且保重存取順序

用LinkedHashList,基于哈希表和雙鏈表,效率低于HashSet

5.如果想對集合中的元素進行排序

用TreeSet,基于紅黑樹,后續(xù)可以用List集合實現(xiàn)排序

http://www.risenshineclean.com/news/7795.html

相關(guān)文章:

  • 做網(wǎng)站找哪個軟件網(wǎng)店運營具體做什么
  • 海珠區(qū)疫情嚴重嗎鄭州seo代理外包
  • 優(yōu)秀的網(wǎng)站首頁布局360競價推廣
  • 案例建網(wǎng)站網(wǎng)址域名ip查詢
  • 17做網(wǎng)店網(wǎng)站池尾東莞網(wǎng)站設(shè)計公司排名
  • 渭南公司做網(wǎng)站百度競價是什么意思
  • 澳門網(wǎng)站后綴開發(fā)外包網(wǎng)站
  • 重慶網(wǎng)站seo服務(wù)線上平臺推廣方案
  • 泰州高端網(wǎng)站建設(shè)如何收費搜索引擎優(yōu)化的簡稱
  • seo做的最好的網(wǎng)站排行青島優(yōu)化網(wǎng)站關(guān)鍵詞
  • wordpress打開文章響應(yīng)慢天津谷歌優(yōu)化
  • 網(wǎng)站建設(shè)編寫代碼出錯東莞seo優(yōu)化推廣
  • 南寧做網(wǎng)站開發(fā)的公司有哪些怎么寫網(wǎng)站
  • 韓國設(shè)計欣賞網(wǎng)站個人推廣網(wǎng)站
  • 棗莊專業(yè)做網(wǎng)站企業(yè)網(wǎng)站建設(shè)的目的
  • 網(wǎng)站內(nèi)容圖片怎么做windows7優(yōu)化大師
  • 南京做微網(wǎng)站蘇州seo關(guān)鍵詞優(yōu)化報價
  • 深圳b2b網(wǎng)站建設(shè)排名南寧seo優(yōu)勢
  • 做個門戶網(wǎng)站多少錢汕頭最好的seo外包
  • 網(wǎng)站建設(shè)用什么軟件鄭州官網(wǎng)網(wǎng)站推廣優(yōu)化公司
  • 網(wǎng)站門戶建設(shè)流程武漢最新疫情
  • 網(wǎng)站的產(chǎn)品中心怎么做國際新聞快報
  • 三明網(wǎng)站建設(shè)虛擬主機搭建網(wǎng)站
  • 做外貿(mào)生意最好的網(wǎng)站國外搜索引擎網(wǎng)站
  • 青島城鄉(xiāng)建設(shè)委員會網(wǎng)站西安網(wǎng)站seo廠家
  • 河間網(wǎng)站建設(shè)公司創(chuàng)建網(wǎng)站需要多少資金
  • 如何做網(wǎng)站的源碼23歲老牌網(wǎng)站
  • wordpress 留言板 插件seo排名查詢
  • 攝影網(wǎng)站 蜂鳥seo網(wǎng)址
  • 長沙網(wǎng)站建設(shè)有限公司網(wǎng)絡(luò)推廣的概念