当前位置:网站首页>LinkedList学习
LinkedList学习
2022-06-29 02:31:00 【为什么不好好卖蛋饼】
数据结构的不同导致特点不同,链表结构擅长处理新增删除问题(只需要修改少量的元素的指针即可),而数组适合处理查询(数组下标方便定位)
代码如下
先进先出队列,链表形式实现。
元素之间通过存储彼此的位置信息实现连接,查找慢,添加/删除快。
不存在数据移动的问题,只需要修改后继指针。
public static void main(String[] args) {
LinkedList list = new LinkedList();
list.add("hello");
list.add("world");
System.out.println(list);
list.addFirst("A");
list.addLast("B");
System.out.println(list);
list.add(2,"2");
System.out.println(list);
//先进先出 从左边加
list.push("javase");
System.out.println(list);
System.out.println(list.getFirst());
System.out.println(list.peek());
System.out.println(list.peekFirst());
//将值取出来,不存在了
System.out.println(list.pop());
System.out.println(list);
}

边栏推荐
- [redis] sortedset type
- thinkphp5.1 runtime文件改成777权限了, 还是无法写入
- 短视频平台常见SQL面试题,你学会了吗?
- Junior final exam
- 【Redis】Key的层级结构
- Centos7 installation php7.2
- Download and installation of MySQL
- MySQL queries the data of today, yesterday, this week, last week, this month, last month, this quarter, last quarter, this year, last year
- Has Moore's law come to an end?
- 温度转换 II
猜你喜欢

安装kibana

They all talk about interviews with big factories. When I interview with small factories, I invite people to drink tea?

Relationship between EMC, EMI and EMS

三角函数计算

高并发的理解与设计方案

To apply for a test engineer after years, the resume with high scores should be written like this

Ctfhub web SQL injection - integer injection

對補wasm環境的一些測試
![[untitled]](/img/36/2f9319e05157ab6a8dd5aa3bef4505.png)
[untitled]

Has Moore's law come to an end?
随机推荐
字符串长度
QT basics tutorial: data types and containers
How to use project Gantt chart to make project report
[redis] list type
Understanding and design of high concurrency
【无标题】
String output
CTFHub-Web-密码口令-默认口令
Why should the pointer be null after delete
Pyinstaller打包pikepdf失败的问题排查
哪个证券公司最大最安全 哪家券商服务好
信息学奥赛一本通 1361:产生数(Produce)
Temperature conversion II
Pvcreate ASM disk causes abnormal recovery of ASM disk group - sparing separation
[redis] key hierarchy
[learning notes] subsets and questions
Centos7 installation php7.2
"The first share of endoscope" broke into IPO two times. Last year, it lost 500million yuan. The commercialization of core products is still in doubt | IPO Express
e.target与e.currentTarget的区别
leetcode 统计无向图中无法互相到达点对数