当前位置:网站首页>List in set (2)
List in set (2)
2022-06-30 06:18:00 【Java shaping】
Catalog
One 、List frame
/----Collection Interface : Single column set , Objects used to store one by one
/----List Interface : Stored in order , Repeatable data ( The dynamic array ) Used to replace the original array
/----ArrayList: As List The main implementation class of the interface , Threads are not safe , Efficient , Bottom use Object[] elementDate Storage
/----LinkedList: For frequent inserts 、 Delete operation , Efficient than ArrayList higher , The bottom layer uses a double linked list
/----Vector: As List The old implementation class of the interface , Thread safety , Low efficiency , Bottom use Object[] elementDate Storage Two 、List Common methods in
void add(int index, object ele): stay index Position insert ele Elements boolean addAlL(int index, collection eles): from index The position will begin eLes Add all the elements in object get(int index)∶ Get specified index The element of location int indexof(object obj): return obj The first place in the set int lastIndexof(object obj): return obj The last position in the current set object remove(int index): Remove the specified index The element of location , And return this element object set(int index,objectele): Set the specified index The element of position is eLe List sublist(int fromIndex, int toIndex): Return from fromIndex To toIndex Subsets of positions
summary : Common methods
increase : add(object obj)
Delete : remove(int index) / remove(0bject obj)
Change : set(int index, object ele)
check : get(int index)
insert : add(int index,object ele)
length :size()
Traverse :Iterator Iterator mode : First use iterator() Generate something like a pointer ,while(iterator.hasNext){ Output next()}
enhance for loop :for( type local variable : The array or collection to traverse )
The normal cycle : combination get Method public class ListTest {
@Test
public void test() {
ArrayList list = new ArrayList();
list.add(123);
list.add(345);
list.add("aa");
list.add(new Person(12, "tom"));
List integers = Arrays.asList(1, 23, 4);
list.add(integers);//[123, 345, aa, Person{age=12, name='tom'}, [1, 23, 4]]
// It's on it addAll Words ,1,23,4 Three data
System.out.println(list);
}
}边栏推荐
- MySQL log management, data backup and recovery
- Completabilefuture: from understanding to mastering, here are all you want to know
- Use and principle of completionservice (source code analysis)
- Cocos studio3.1 installation package win
- 从底层结构开始学习FPGA----RAM IP核及关键参数介绍
- JS prototype chain object function relationship
- MySQL事物
- Golang之手写web框架
- Installation and initialization of MariaDB database
- 01. regular expression overview
猜你喜欢
随机推荐
ES6扩展运算符(...)
ES6 array traversal and Es5 array traversal
Use of observer mode and status mode in actual work
STM32F103 series controlled OLED IIC 4-pin
How does Altium designer hide some temporarily unnecessary classes, such as GND
Installing googleplay environment on Huawei mobile phones
ini解析学习文档
Simple example of class template
【微信小程序:单选、多选样式,背景色,圆角】
InputStream to inputstreamsource
Title: enter two positive integers m and N to find their maximum common divisor and minimum common multiple
Completabilefuture: from understanding to mastering, here are all you want to know
【学习强化学习】总目录
Installation and initialization of MariaDB database
谁不想要一个自己的博客网站呢 - 搭建博客网站wordpress
880. 索引处的解码字符串
My experience in functional testing for so many years
Talking about the struct of go
JS prototype chain object function relationship
To: k210 realizes face recognition (code interpretation attached)







![[GPU] basic operation](/img/76/6b22368e3addd30aef1dd2258ee49a.jpg)

![[MD editing required] welcome to the CSDN markdown editor](/img/6c/df2ebb3e39d1e47b8dd74cfdddbb06.gif)