Java learning notes 18 -- generics of collection classes
Java programming foundation penultimate article, thank you for not giving up yourself. This column is temporarily over, and the next step is to fix the algorithm. Zhang Huansheng, editor in chief of the reference book "Fundamentals of Java programming". The content of this book is more suitable for beginners without any foundation. Th ...
Posted by slickboyj on Sun, 24 Oct 2021 12:15:30 -0700
Together, let's go to the Java collection world to find out—— Collection & List
catalogue
preface
1, Collection collection
1. Collection characteristics and architecture
2.Collection collection overview and basic usage
3. Common methods and traversal of collection
4. Collection case - the collection stores student objects and traverses them
2, List collection
1.List set overview, features and unique methods
2. Con ...
Posted by garfx on Fri, 22 Oct 2021 04:53:20 -0700
Java - JUC high concurrency programming, interview must ask (thread safety of collection)
4 thread safety of collections
4.1 set operation Demo (demonstration)
NotSafeDemo:
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
/*** Collection thread safety case
*/
public class NotSafeDemo {
/**
* Multiple threads modify the collection at the same time
*/
public static void main(String[] args) {
L ...
Posted by IsmAvatar on Wed, 20 Oct 2021 23:08:42 -0700
Those unknown secrets about Map collection
preface
In the last issue, we talked about the Collection Set. It is a single column Set, which is divided into List Set and Set set Set. Today, I will continue to analyze a double column Set, that is, Map. Why is it called a double column Set? Look down and you'll see.
catalogue
1, Map
2, Basic concepts of HashMap
3, Ba ...
Posted by cronus on Tue, 19 Oct 2021 17:32:33 -0700
JavaSE_ Knowledge point (lower 1) (set, IO stream)
Java -- collection, IO stream
1. Set (java.util. *)
(1) 1. Overview
I. a set is actually a container (carrier) that can store multiple objects; (array is the simplest set); II. The basic data type and java object cannot be stored in the collection, but the memory address of the java object is stored; III. the bottom layer of each diff ...
Posted by rotwyla98 on Wed, 13 Oct 2021 22:17:09 -0700
ArrayList of Java Foundation
1. General
ArrayList implements the List interface and is a sequential container, that is, the data stored in the elements is in the same order as that put in. null elements are allowed to be put in, and the bottom layer is realized through array. Except that this class does not realize synchronization, the rest are roughly the same as Vec ...
Posted by padiwak on Thu, 07 Oct 2021 21:40:57 -0700
Unsafe solution of Java collection class under multithreading
2, Collection class unsafe
2.1ArrayList thread is unsafe
2.1.1 example
Single thread
public class NotSafeDemo {
//Single thread is safe
public static void main(String[] args) {
List<String> list = Arrays.asList("a", "b", "c");
list.forEach(System.out::println);
}
}
a
b
c
Multithreading
public class NotS ...
Posted by coffeehead on Sat, 25 Sep 2021 04:51:09 -0700
Two column set Map
Double column set: key: value
public class MapDDDDemo {
public static void main(String[] args) {
Map map = new HashMap<Integer,String>();
map.put(1,"Hello");
map.put(2,"world");
map.put(3,"hello");
System.out.println("map Length:"+map.size());
System.out.println("map Include key ...
Posted by joshuamd3 on Fri, 24 Sep 2021 21:36:05 -0700
Java Collection source code summary Collection source code annotation translation and analysis in both Chinese and English
edition JDK8(JDK1.8)
Collection interface source code focus 1. The root interface in the set hierarchy. A set represents a group of objects called its elements. Some sets allow repeated elements, while others do not. Some are ordered and some are disordered.
2. The interface class defines various specifications, including method specification ...
Posted by Opticon on Fri, 24 Sep 2021 21:13:19 -0700
Set - Map interface
Characteristics of Map interface implementation class
Map and Collection exist side by side. Used to save data with mapping relationship: key valueThe key and value in the Map can be data of any reference type and will be encapsulated in the HashMap$Node objectDuplicate key s in Map are not allowed. The reason is the same as HashSet. The sourc ...
Posted by pinehead18 on Thu, 23 Sep 2021 04:15:21 -0700