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

网站 建设 毕业设计 要求百度关键词优化方法

网站 建设 毕业设计 要求,百度关键词优化方法,网站开发模板图片,网站建设下什么费用List接口: 继承自Collection接口,List集合是可重复集合,并且有序,还提供了一套可以通过下标来操作元素的方法 常见的实现类: ArrayList:内部使用数组实现,查询性能更好(直接下标找到物理地址)、…

List接口:

  • 继承自Collection接口,List集合是可重复集合,并且有序,还提供了一套可以通过下标来操作元素的方法

  • 常见的实现类:

    • ArrayList:内部使用数组实现,查询性能更好(直接下标找到物理地址)、增删性能不好

    • LinkedList:内部使用链表实现,查询性能不好,首尾增删性能好

      注意:在对集合操作的增删性能没有特别苛刻的要求时,通常选择ArrayList

List集常用方法:

  • get():根据下标获取元素

  • set():将指定元素设置到指定位置,并返回被替换的元素(用时才接收)

  • 重载remove():删除指定位置元素,并返回被删除的元素(用时才接收)

  • 重载add():将指定元素添加到指定位置,理解为插入操作

public class ListDemo {public static void main(String[] args) {List<String> list = new LinkedList<>();list.add("one");list.add("two");list.add("three");list.add("four");list.add("five");list.add("one");System.out.println("list:"+list); //[one, two, three, four, five, one]//E get(int index):获取指定下标所对应的元素String e = list.get(2);System.out.println(e); //threefor(int i=0;i<list.size();i++){System.out.println(list.get(i));}Iterator<String> it = list.iterator();while(it.hasNext()){System.out.println(it.next());}for(String s : list){System.out.println(s);}System.out.println("-----------------------------");/*E set(int index, E e):将给定元素设置到指定位置,返回被替换的元素*///list.set(2,"six"); //将list中下标为2的元素设置为six---常规用法String old = list.set(2,"six"); //将list中下标为2的元素设置为six,同时将原数据返回oldSystem.out.println("list:"+list); //[one, two, six, four, five, one]System.out.println(old); //three/*E remove(int index):删除指定位置元素,并返回指定位置元素*///list.remove(2); //删除下标为2的元素---常规用法String s = list.remove(2); //删除下标为2的元素,并将被删除元素返回给sSystem.out.println("list:"+list); //[one, two, four, five, one]System.out.println(s); //six/*void add(int index,E e):将给定元素e添加到index所指定的位置,相当于插入操作*/list.add(3,"seven"); //在list下标为3的位置插入sevenSystem.out.println(list); //[one, two, four, five, one]}
}

subList():获取集合的子集(含头不含尾)

public class SubListDemo {public static void main(String[] args) {/*List提供了获取子集的操作:List subList(int start,int end):含头不含尾*/List<Integer> list = new ArrayList<>();for(int i=0;i<10;i++){list.add(i*10);}System.out.println("list:"+list); //[0, 10, 20, 30, 40, 50, 60, 70, 80, 90]List<Integer> subList = list.subList(3,8); //获取下标3到7的子集System.out.println("subList:"+subList); //[30, 40, 50, 60, 70]//将子集每个元素都扩大10倍for(int i=0;i<subList.size();i++){subList.set(i,subList.get(i)*10);}System.out.println("subList:"+subList); //[300, 400, 500, 600, 700]//注意:对子集的操作就是对原集合对应的元素操作System.out.println("list:"+list); //[0, 10, 20, 300, 400, 500, 600, 700, 80, 90]list.set(3,1000); //将原集合下标为3的元素的数据修改为1000System.out.println("list:"+list); //[0, 10, 20, 1000, 400, 500, 600, 700, 80, 90]//原集合数据改变后,子集数据跟着变了System.out.println("subList:"+subList); //[1000, 400, 500, 600, 700]list.remove(0);System.out.println("list:"+list); //[10, 20, 1000, 400, 500, 600, 700, 80, 90]//原集合长度修改之后,子集将不能再进行任何操作,操作则发生异常,但是可以重新获取子集System.out.println("subList:"+subList); //运行时发生不支持修改异常}
}

集合排序:

  • Collections为集合的工具类,里面定义了很多静态方法用于操作集合

  • Collections.sort(List list)方法:可以对list集合进行自然排序(从小到大),但是其要求List集合中的元素必须是可比较的,判断是否可以比较的标准是元素是否实现了Comparable接口,若没有实现该接口则直接发生编译错误,但是在实际开发中,我们一般是不会不让我们自己写的类去实现Comparable接口的,因为这对我们的程序有侵入性。

  • 侵入性:当我们调用某个API功能时,其要求我们为其修改其它额外的代码,这个现象叫做侵入性。侵入性越强越不利于程序的后期维护,应尽量避免。

  • 建议使用重载的Collections.sort(List list, Comparator o);可以通过Comparator来自定义比较规则

public class SortInteger {public static void main(String[] args) {Random rand = new Random();List<Integer> list = new ArrayList<>();for(int i=0;i<10;i++){list.add(rand.nextInt(100));}System.out.println("list原始数据:"+list); //无序Collections.sort(list); //自然排序(从小到大)System.out.println("list排序后数据:"+list); //有序(小到大)Collections.reverse(list); //反转list集合(数据已经改变了)System.out.println("list反转后数据:"+list);System.out.println("第1个元素为:"+list.get(0)); //输出第1个元素/*List<String> list = new ArrayList<>();list.add("jack");list.add("rose");list.add("tom");list.add("jerry");list.add("black");list.add("Kobe");System.out.println("list原始数据:"+list); //[jack, rose, tom, jerry, black, Kobe]//对英文字符串排序时,会按首字母的ASCII码来排//若首字母相同,则比较第2个字母的ASCII码,以此类推Collections.sort(list);System.out.println("list排序后数据:"+list); //[Kobe, black, jack, jerry, rose, tom]*/}
}public class SortPoint {public static void main(String[] args) {List<Point> list = new ArrayList<>();list.add(new Point(5,8));list.add(new Point(15,60));list.add(new Point(57,89));list.add(new Point(1,4));list.add(new Point(10,8));list.add(new Point(22,35));System.out.println("list原始数据:"+list);//jdk1.8时,List集合自身提供了sort方法进行排序,方法中需要传入比较器list.sort(new Comparator<Point>() {public int compare(Point o1, Point o2) {return o1.getX()-o2.getX();}});System.out.println("list排序后数据:"+list);list.sort((o1,o2)->{int len1 = o1.getX()*o1.getX()+o1.getY()*o1.getY();int len2 = o2.getX()*o2.getX()+o2.getY()*o2.getY();return len1-len2; //升序});/*//自定义排序规则:Collections.sort(list, new Comparator<Point>() {public int compare(Point o1, Point o2) {int len1 = o1.getX()*o1.getX()+o1.getY()*o1.getY();int len2 = o2.getX()*o2.getX()+o2.getY()*o2.getY();//return len1-len2; //升序return len2-len1; //降序//return o1.getX()-o2.getX(); //按x坐标升序//return o2.getY()-o1.getY(); //按y坐标降序}});*/Collections.sort(list,(o1,o2)->{int len1 = o1.getX()*o1.getX()+o1.getY()*o1.getY();int len2 = o2.getX()*o2.getX()+o2.getY()*o2.getY();return len1-len2; //升序});System.out.println("list排序后数据:"+list);}
}

Lambda表达式:

  • JDK1.8之后推出了一个新特性:Lambda表达式

  • 规则:

    1. 不是任何匿名内部类都可以转换为Lambda表达式

    2. Lambda表达式对接口的要求:只能是函数式接口

    3. 函数式接口:接口中要求实现类必须重写的方法只有一个

语法:

(参数列表)->{方法体
}
public class LambdaDemo {public static void main(String[] args) {List<String> list = new ArrayList<>();//匿名内部类写法Collections.sort(list, new Comparator<String>() {public int compare(String o1, String o2) {return o1.length()-o2.length();}});//Lambda表达式写法Collections.sort(list, (String o1, String o2) -> {return o1.length()-o2.length();});//Lambda表达式中的参数类型可以不写Collections.sort(list, (o1, o2) -> {return o1.length()-o2.length();});//Lambda表达式方法体中只有一句代码,方法体的{}可以不写,如果这句话中有return,也一并不写Collections.sort(list, (o1, o2) -> o1.length()-o2.length());//Lambda表达式的方法参数只有1个,那么()可以忽略不写---本案例不适用}
}

Set接口:

不可重复集合,并且大部分实现类都是无序的

public class SetDemo {public static void main(String[] args) {Set<String> set = new HashSet<>();set.add("one");set.add("two");set.add("three");set.add("four");set.add("five");set.add("two"); //无法被正确添加进去,因为Set集是不可重复集合,并且大部分都无序System.out.println(set);}
}

小面试题:如何去重?

public class SetDemo {public static void main(String[] args) {//小面试题:如何去重?List<String> list = new ArrayList<>();list.add("one");list.add("two");list.add("three");list.add("four");list.add("five");list.add("two");System.out.println("list:"+list); //[one, two, three, four, five, two]Set<String> set = new HashSet<>();set.addAll(list); //将list集合元素都添加到set集合中System.out.println("set:"+set); //[four, one, two, three, five]}
}

什么是二进制:逢2进1的计数规则。计算机中的变量/常量都是按照2进制来计算的

  • 2进制:

    • 规则:逢2进1

    • 数字:0 1

    • 基数:2

    • 权:128 64 32 16 8 4 2 1

  • 如何将2进制转换为10进制:

    • 正数:将二进制每个1位置的权相加

权:     32  16  8  4  2  1
二进制:  1   0   1  1  0  1
十进制:  32+8+4+1=45权:     32  16  8  4  2  1
二进制:  1   0   0  1  1  0
十进制:  32+4+2=38

注:

十进制:

  • 规则:逢10进1

  • 数字:0 1 2 3 4 5 6 7 8 9

  • 基数:10

  • 权:十万 万 千 百 十 个

10的0次幂------------------1
10的1次幂------------------10
10的2次幂------------------100
10的3次幂------------------1000
10的4次幂------------------10000

二进制:

  • 规则:逢2进1

  • 数字:0 1

  • 基数:2

  • 权:512 256 128 64 32 16 8 4 2 1

2的0次幂------------------1
2的1次幂------------------2
2的2次幂------------------4
2的3次幂------------------8
2的4次幂------------------16
2的5次幂------------------32

十六进制:逢16进1

  • 规则:逢16进1

  • 数字:0 1 2 3 4 5 6 7 8 9 a b c d e f

  • 基数:16

  • 权:65536 4096 256 16 1

16的0次幂------------------1
16的1次幂------------------16
16的2次幂------------------256
16的3次幂------------------4096
16的4次幂------------------65536

权的由来:基数的几次幂


文章转载自:
http://concentrator.fwrr.cn
http://colonelcy.fwrr.cn
http://hallstattian.fwrr.cn
http://wheelwright.fwrr.cn
http://lobbyman.fwrr.cn
http://longeur.fwrr.cn
http://neigh.fwrr.cn
http://naivete.fwrr.cn
http://pubertal.fwrr.cn
http://waterproof.fwrr.cn
http://beefy.fwrr.cn
http://blackwall.fwrr.cn
http://waygoing.fwrr.cn
http://crocean.fwrr.cn
http://countercharge.fwrr.cn
http://tenantship.fwrr.cn
http://dieb.fwrr.cn
http://enfold.fwrr.cn
http://jussive.fwrr.cn
http://fractionalize.fwrr.cn
http://handcraft.fwrr.cn
http://zygal.fwrr.cn
http://pdd.fwrr.cn
http://arillate.fwrr.cn
http://entad.fwrr.cn
http://preflight.fwrr.cn
http://sanjak.fwrr.cn
http://telemetry.fwrr.cn
http://minicalculator.fwrr.cn
http://legislation.fwrr.cn
http://crystalligerous.fwrr.cn
http://mshe.fwrr.cn
http://habdalah.fwrr.cn
http://colluvium.fwrr.cn
http://dineutron.fwrr.cn
http://vries.fwrr.cn
http://restyle.fwrr.cn
http://cellarman.fwrr.cn
http://refinery.fwrr.cn
http://dumpish.fwrr.cn
http://mouthbreeder.fwrr.cn
http://nipplewort.fwrr.cn
http://resh.fwrr.cn
http://hardwood.fwrr.cn
http://lindesnes.fwrr.cn
http://aerostatics.fwrr.cn
http://insolvable.fwrr.cn
http://flunkey.fwrr.cn
http://vida.fwrr.cn
http://dwarf.fwrr.cn
http://upi.fwrr.cn
http://kroon.fwrr.cn
http://interpreter.fwrr.cn
http://tautochronous.fwrr.cn
http://oid.fwrr.cn
http://punctulate.fwrr.cn
http://yakitori.fwrr.cn
http://congress.fwrr.cn
http://lacertilian.fwrr.cn
http://floorage.fwrr.cn
http://viewport.fwrr.cn
http://polymorphonuclear.fwrr.cn
http://yearly.fwrr.cn
http://equiangular.fwrr.cn
http://bicycler.fwrr.cn
http://narcolepsy.fwrr.cn
http://colorblind.fwrr.cn
http://townswoman.fwrr.cn
http://wergeld.fwrr.cn
http://extendable.fwrr.cn
http://grumous.fwrr.cn
http://syphilis.fwrr.cn
http://captor.fwrr.cn
http://delightsome.fwrr.cn
http://hemisphere.fwrr.cn
http://shrank.fwrr.cn
http://naillike.fwrr.cn
http://flabellifoliate.fwrr.cn
http://colorplate.fwrr.cn
http://enlink.fwrr.cn
http://peccary.fwrr.cn
http://dismiss.fwrr.cn
http://resplend.fwrr.cn
http://unpeaceful.fwrr.cn
http://revisit.fwrr.cn
http://roundhouse.fwrr.cn
http://laden.fwrr.cn
http://resonance.fwrr.cn
http://sned.fwrr.cn
http://earthfall.fwrr.cn
http://looseness.fwrr.cn
http://rotary.fwrr.cn
http://anima.fwrr.cn
http://deodorization.fwrr.cn
http://parsimonious.fwrr.cn
http://mazel.fwrr.cn
http://alpinist.fwrr.cn
http://chilli.fwrr.cn
http://serenely.fwrr.cn
http://immobilon.fwrr.cn
http://www.dt0577.cn/news/101519.html

相关文章:

  • 济南富新网站建设百度首页推荐关不掉吗
  • 网站建设制作宝塔面板怎么开网店
  • 大淘客网站如何做制作深圳网络营销策划有限公司
  • 塔城市建设局网站搜索优化的培训免费咨询
  • 封面上的网站怎么做的网站排名查询工具
  • 网站设计和管理容易吗非企户百度推广
  • 微信网站开发价格域名解析ip
  • 网站收录需要多久搜索引擎地址
  • 网站模板免费下载网站最新新闻消息
  • 12306网站建设多少钱链接交换
  • 恐怖音乐怎么做的视频网站运用搜索引擎营销的案例
  • 怎么做自己地网站建立网站要多少钱一年
  • 竹子建站怎么样搜索引擎推广一般包括哪些
  • 如何在局域网中做网站成都seo公司排名
  • 请将uploads里面的所有文件和文件夹上传到你的网站根目录栾城seo整站排名
  • 品牌设计培训网站在线优化工具
  • wordpress装修网插件前端性能优化
  • 网站空间怎么续费公司网站策划宣传
  • 做家装图接单网站注册网站
  • 企业网站建设注意北京专业网站优化
  • 如何零基础做网站免费可用的网站源码
  • 沈阳的网站建设班级优化大师官方网站
  • sexinsexurl wordpressseo 百度网盘
  • 营销型类型网站有哪些类型seo翻译
  • 帮别人做网站 别人违法营销型网站的分类不包含
  • 用哪个网站做相册视频谷歌seo顾问
  • 做电商需要知道的几个网站吗查关键词
  • 泊头做网站的有哪些如何建立一个自己的网站啊
  • 网站建设都用哪些软件网站怎样关键词排名优化
  • wordpress开发的主流架构seo引擎优化外包