collection container interface
set cannot be repeated unordered
list can be repeated ordered
hashMap ->map find objects through objects
list can be repeated ordered
hashMap ->map find objects through objects
iterator iterates over a container
link
ArraryList Thread unsafe High efficiency Low-level implementation is array Query, block join and delete slow
LinkList Thread unsafe High efficiency Low-level implementation is linked list Slow query Add block
Vector Thread safe Low efficiency
LinkList Thread unsafe High efficiency Low-level implementation is linked list Slow query Add block
Vector Thread safe Low efficiency
System.Arrarycopy();
Array copy
Array copy
Map key (key)-value (value) segment health does not repeat
Map.put (key, value) one-to-one put similar correlation
Map.put (key, value) one-to-one put similar correlation
hashMap() thread unsafe high efficiency
hashTable() thread safe high efficiency
hashTable() thread safe high efficiency
The bottom layer of set is Map, the
default hashcode is calculated according to the address
The bottom layer of hasdset is hasdmap and the object of hashset is used as the key of hashmap
remove according to
set hash
After adding generics to the container, only one type of object can be added
List<Student> list = new ArraryList<Student>();
List<Student> list = new ArraryList<Student>();
javabean entity class properties are similar to set and get methods
map
map
Iterator interface (iterator) container variable
First get the iterator then loop
Student<T1,T2>
Student<String,Integer> cannot be static Basic data type
T type
kv key value
In a generic interface interface, generic letters can be used in methods but not in constants
Generic method can only get information cannot be modified
public static <T> void test(T a) {
System.out.println();
}
Generic type Automatically check polymorphic type
public static <T> void test(T a) {
System.out.println();
}
Generic type Automatically check polymorphic type
The parent class is a generic class
public abstract class Father<T> {
}
Subclass (1) Class class child1 extends Father<String> {
}
(2) When using a generic class, make sure the number is the same as the number of letters of the parent class
type child2<T> extends Father(T) {
}
(3) The subclass is a generic class, and the parent class does not specify a type. Generic
erasure class child3<T1> extends Father{
}
(4) Subclass erasures parent class erasure except
class child4 extends Father {
}
public abstract class Father<T> {
}
Subclass (1) Class class child1 extends Father<String> {
}
(2) When using a generic class, make sure the number is the same as the number of letters of the parent class
type child2<T> extends Father(T) {
}
(3) The subclass is a generic class, and the parent class does not specify a type. Generic
erasure class child3<T1> extends Father{
}
(4) Subclass erasures parent class erasure except
class child4 extends Father {
}
In the parent class follow the parent classIn the subclass follow the subclass
Override follow the parent class
Override follow the parent class
Paradigm without polymorphism Can't be used on
classes ?
extends <= upper limit
super >= lower limit
classes ?
extends <= upper limit
super >= lower limit
generic nesting
No generic array
can be declared available?
can be declared available?
jdk1.7 can A<String> x = new A<>();
Use generics Do not specify a type Erase the default Object
but customize the Object by yourself Not erasing but comparing with Object when using
but customize the Object by yourself Not erasing but comparing with Object when using
Enhanced for must implement iterator and enhanced for is iterator
Java.lang.Iterable interface
Java.lang.Iterable interface
The built-in sorting system implements the Comparable interface and overrides the
CompareTo() method
Our custom sorting needs to implement the Compare method of the Comparator interface
TreeSet
The data cannot be modified when used, otherwise the sorting may be disrupted
because it is sorted when placed
because it is sorted when placed
Use final modifier
hashMap hashTable difference
hashtable thread safety relatively low synchronization efficiency
hashmap thread safety asynchronous high efficiency
parent class hashtable Dictionry hashMap AbstractMap
null hashtable key and value cannot be null
hashMap health at most one null value can be multiple Null
Properties Read and
write resource configuration files
Values and keys can only be strings
The suffix is properties
byte stream
character
stream.xml
The WeakhashMap key is a weak reference gc immediately reclaims
the IdentityMap key and compares the address Note that the constant pool object
EnumMap enumerates the Map key is the enumeration value
Collections manage synchronization, that is, the container becomes a thread-safe container
SynchronizationXXX();
Collections, synchronizationList();
Collection read-only set
empty
empty
https://code.google.com/p/guava-libraries/
ByteArrayOutputStream needs to save the data in the node stream to byteArrayOutputStream and then unify the
bos, toByteArray() method and output it to the byte array
Reference Type Data + Type
Serialization Input Stream ObjectInputStream
Deserialization Output Stream ObjectOutputStream
Serialization and deserialization are in the same order
Not all objects can be serialized must implement the java.io.Serializable interface
Not all properties need to be serialized Do not want a property to be serialized
private transient String name;
public static void close(Closeanle ... io)
variable parameters (number) can only be placed at the end
variable parameters (number) can only be placed at the end
1.7 New features try --- with --- resource
automatically closes the same after compilation
printstream = system.out;
redirect
RandAccessFile random read can be used for file splitting
RandAccessFile(src."r") read only
sequenceInputStream merges two streams
uses Vector to store enumeration streams
uses Vector to store enumeration streams