当前位置:网站首页>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);
}
}边栏推荐
- ES6 arrow function
- How does Altium designer hide some temporarily unnecessary classes, such as GND
- 【微信小程序:单选、多选样式,背景色,圆角】
- Spin official tutorial
- DXP copper laying settings
- Win10 /11 开热点无法上网问题
- 关于Glide加载图片模糊不清楚
- Completabilefuture: from understanding to mastering, here are all you want to know
- MySQL index
- When to use redis
猜你喜欢

Mysql database learning notes - foreign keys, table connections, subqueries, and indexes for MySQL multi table queries

接口中方法详解

观察者模式、状态模式在实际工作中的使用

SHELL

Installation and initialization of MariaDB database
![[wechat applet: single or multiple styles, background color, rounded corners]](/img/01/0381915591b0d3c13afbba4d50952d.png)
[wechat applet: single or multiple styles, background color, rounded corners]

Golang's handwritten Web Framework

Mariadb数据库的安装与初始化

MySQL 索引
![[MD editing required] welcome to the CSDN markdown editor](/img/6c/df2ebb3e39d1e47b8dd74cfdddbb06.gif)
[MD editing required] welcome to the CSDN markdown editor
随机推荐
Network basics
File operation io-part1
Using C language pure for loop to implement ilovey
Master slave synchronization of MySQL database to realize read-write separation
583. deleting two strings - Dynamic Planning
MySQL summary
STM32F103 series controlled OLED IIC 4-pin
Record a problem tracking of excessive load
Golang之手写web框架
ES6 arrow function
PHP knowledge points
图片。。。。。
Idea run SQL file
Idea add database
Base64 explanation: playing with pictures Base64 encoding
When to use redis
Image processing 7- image enhancement
【数据库】事务
One sentence introduction to Trojan horse
Verilog中case,casez,casex语句的用法