当前位置:网站首页>List introduction
List introduction
2022-06-30 10:51:00 【Warm the sun like the wind】

️ Preface ️
This article mainly introduces Iterable、Collection、List Common method signatures and their meanings , The relationship between the three is described below .
Blog home page :【 Warm the sun like the wind 】
The high-quality goods Java special column 【JavaSE】、【 Prepare for blue bridge 】、【JavaEE The first step 】、【MySQL】、【 data structure 】
Welcome to thumb up Collection Leave a comment Private letters must be answeredThis paper is written by 【 Warm the sun like the wind 】 original , First appeared in CSDN
Bloggers will continue to update their learning records and gain , If you have any questions, you can leave a message in the comment area
The source code involved in the blog and the daily practice code of the blogger have been uploaded Code cloud (gitee)、GitHub
Iterable、Collection、List
1. The diagram
In the set framework , The relationship between the three is as follows , All three are interfaces 
2.Iterable
Iterable Is a generic interface with iteration function , Indicates that the class implementing the interface can be traversed element by element .
public interface Iterable<T> {
Iterator<T> iterator();
// Abstract methods in abstract classes
default void forEach(Consumer<? super T> action) {
Objects.requireNonNull(action);
for (T t : this) {
action.accept(t);
}
}
default Spliterator<T> spliterator() {
return Spliterators.spliteratorUnknownSize(iterator(), 0);
}
}
Its internal implementation is through foreach Loop or call iterator() Method to implement traversal .
3.Collection
Collection It is inherited from Iterable The generic interface of , The interface used to implement the collection .
public interface Collection<E> extends Iterable<E>{
};
Common method signature :
| Method | effect |
|---|---|
| add(Object o) | Add an element to the collection |
| addAll(Collection c) | Add a collection to a collection c All elements of |
| clear() | Remove all elements |
| contains(Object o) | Determine whether the collection contains the element |
| containsAll(collection c) | Determine whether a set contains a set c The elements of |
| isEmpty() | Determines if the set is empty |
| iteration() | return iteration object , Used to traverse all elements in the collection |
| remove(Object o) | Delete a specified element |
| removeAll(collection c) | Delete the collection c All elements in |
| retainAll(Collection c) | Keep collections only c The elements that appear in |
| int size() | Returns the number of elements in the collection |
| Object[] toArray() | Convert a set into an array |
4.List
List It's a linear table , namely n A finite sequence of elements of the same type , On this sequence, operations such as adding, deleting, modifying and querying variables can be performed .
Be careful :
List It's an interface , It cannot be directly used to instantiate .
If you want to use , Must instantiate List Implementation class of . In the set framework ,ArrayList and LinkedList It's all done List Interface .
Common method tag names :
| Method | effect |
|---|---|
| boolean add(E e) | Tail insertion e |
| void add(int index, E element) | take e Insert into index Location |
| boolean addAll(Collection<? extends E> c) | Tail insertion c The elements in |
| E remove(int index) | Delete index Location elements |
| boolean remove(Object o) | Delete the first o |
| E get(int index) | Get subscript index Location elements |
| E set(int index, E element) | Subscript index The location element is set to element |
| void clear() | Empty |
| boolean contains(Object o) | Judge o Is it in the linear table |
| int indexOf(Object o) | Return to the first o The subscript |
| int lastIndexOf(Object o) | Go back to the last o The subscript |
| List subList(int fromIndex, int toIndex) | Interception part list |
️ Last words ️
Summing up difficulties , hope uu Don't be stingy with your (^U^)ノ~YO!! If there is a problem , Welcome comments and corrections in the comment area

边栏推荐
- 深潜Kotlin协程(十六):Channel
- My in-depth remote office experience | community essay solicitation
- Qt之实现动效导航栏
- 05_ Node JS file management module FS
- 我在鹅厂淘到了一波“炼丹神器”,开发者快打包
- 腾讯云数据库工程师能力认证重磅推出,各界共话人才培养难题
- [proteus simulation] Arduino uno led simulated traffic light
- Apple's 5g chip was revealed to have failed in research and development, and the QQ password bug caused heated discussion. Wei Lai responded to the short selling rumors. Today, more big news is here
- 软件测试工程师面试基础题(应届生和测试小菜必备)最基础的面试题
- Skill combing [email protected] control a dog's running on OLED
猜你喜欢

The intelligent DNA molecular nano robot model is coming

软件测试工程师面试基础题(应届生和测试小菜必备)最基础的面试题

mysql数据库基础:约束、标识列

List介绍
[email protected]體感機械臂"/>技能梳理[email protected]體感機械臂

Qt之实现动效导航栏

Overview of currency

今晚19:00知识赋能第2期直播丨OpenHarmony智能家居项目之控制面板界面设计

再测云原生数据库性能:PolarDB依旧最强,TDSQL-C、GaussDB变化不大
![[deep learning] common methods for deep learning to detect small targets](/img/c6/8f0549864992a1554397bad16dad4d.jpg)
[deep learning] common methods for deep learning to detect small targets
随机推荐
SGD has many improved forms. Why do most papers still use SGD?
Pandora IOT development board learning (HAL Library) - Experiment 1 running lantern (RGB) experiment (learning notes)
mysql数据库基础:约束、标识列
Gd32 RT thread PWM drive function
LVGL 8.2 Simple Image button
我在鹅厂淘到了一波“炼丹神器”,开发者快打包
Circuit breaker hystrixcircuitbreaker
RobotFramework学习笔记:环境安装以及robotframework-browser插件的安装
From introduction to mastery of MySQL 50 lectures (32) -scylladb production environment cluster building
运动App如何实现端侧后台保活,让运动记录更完整?
Criu enables hot migration
CSDN blog operation team 2022 H1 summary
Pytorch notes: validation, model eval V.S torch. no_ grad
DQN笔记
腾讯云数据库工程师能力认证重磅推出,各界共话人才培养难题
Remember the experience of an internship. It is necessary to go to the pit (I)
JS FAQs
Collectors. Tomap application
Compétences Comb 27 @ Body sense Manipulator
滴滴开源敏捷测试用例管理平台!