当前位置:网站首页>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);
}
}边栏推荐
- Golang之手写web框架
- Zibll子比主题V6.4.1wordpress 开心版源码下载_破解原版/直接使用/无需教程
- 01. 正则表达式概述
- Feisheng: Based on the Chinese word breaker ik-2 ways to build custom hot word separators Showcase & pit arrangement Showtime
- 583. deleting two strings - Dynamic Planning
- Ini parsing learning documents
- CompletionService使用及原理(源码分析)
- Intelligent question - horse racing question
- ES6解构赋值
- 反编译正常回编译出现问题自己解决办法
猜你喜欢
随机推荐
Cisco vxlan configuration
我做功能测试这么多年的心得
从底层结构开始学习FPGA----RAM IP核及关键参数介绍
谁不想要一个自己的博客网站呢 - 搭建博客网站wordpress
【微信小程序:单选、多选样式,背景色,圆角】
Golang's handwritten Web Framework
Rhcsa day 3
880. 索引处的解码字符串
[OSPF] comparison between rip and OSPF
MySQL index
[wechat applet: single or multiple styles, background color, rounded corners]
[ansible series] fundamentals -01
Potential bottleneck of redis
股票在网上开户安全吗?在网上能不能开户炒股呢?
Base64 explanation: playing with pictures Base64 encoding
PC viewing WiFi password
Detailed description of methods in the interface
圖像處理7-圖像增强
Idea add database
Feisheng: Based on the Chinese word breaker ik-2 ways to build custom hot word separators Showcase & pit arrangement Showtime









