• 工单项目笔记


    1.SpringBoot中CommandLineRunner的作用

    平常开发中有可能需要实现在项目启动后执行的功能,SpringBoot提供的一种简单的实现方案就是添加一个model并实现CommandLineRunner接口,实现功能的代码放在实现的run方法中


    2.LinkedList(实现了queue,deque接口,List接口)实现栈和队列的功能

    LinkedList是用双向链表结构存储数据的,很适合数据的动态插入和删除,随机访问和遍历速度比较慢

    底层是一个双向链表,链表擅长插入和删除操作,队列和栈最常用的2种操作都设计到插入和删除


    import java.util.LinkedList;
    import java.util.Queue;
    //用linkedList模拟队列,因为链表擅长插入和删除
    public class Hi {
        public static void main(String [] args) { //做剑指offer遇见过这个数结
            Queue<String> queue = new LinkedList<String>();
            //追加元素
            queue.add("zero");
            queue.offer("one");
            queue.offer("two");
            queue.offer("three");
            queue.offer("four");
            System.out.println(queue);//[zero, one, two, three, four]
            //从队首取出元素并删除
            System.out.println(queue.poll());// zero
            System.out.println(queue.remove());//one
            System.out.println(queue);//[two, three, four]
            //从队首取出元素但是不删除
            String peek = queue.peek();
            System.out.println(peek); //two
            //遍历队列,这里要注意,每次取完元素后都会删除,整个
            //队列会变短,所以只需要判断队列的大小即可
            while(queue.size() > 0) {
                System.out.println(queue.poll());
            }//two three four
        }
    }

       

  • 相关阅读:
    hdu 4302 Holedox Eating 夜
    poj 1947 Rebuilding Roads 夜
    hdu 4303 Hourai Jeweled 夜
    poj 1286 Necklace of Beads 夜
    poj 2057 The Lost House 夜
    hdu 4301 Divide Chocolate 夜
    poj 3140 Contestants Division 夜
    BOM(二)
    Str的方法
    求出字符窜的字母的个数
  • 原文地址:https://www.cnblogs.com/zkaiw/p/12795512.html
Copyright © 2020-2023  润新知