类 DataList
- 所有已实现的接口:
Serializable,Cloneable,Iterable<Object>,Collection<Object>,List<Object>,RandomAccess
- 版本:
- 1.0.1
- 作者:
- YYJ
- 另请参阅:
-
字段概要
从类继承的字段 java.util.AbstractList
modCount -
构造器概要
构造器 -
方法概要
修饰符和类型方法说明voidInserts the specified element at the specified position in this list.booleanAppends the specified element to the end of this list.booleanaddAll(int index, Collection<?> c) Inserts all of the elements in the specified collection into this list, starting at the specified position.booleanaddAll(Collection<?> c) Appends all of the elements in the specified collection to the end of this list, in the order that they are returned by the specified collection's Iterator.voidclear()Removes all of the elements from this list.clone()booleanReturnstrueif this list contains the specified element.booleancontainsAll(Collection<?> c) voidensureCapacity(int minCapacity) Increases the capacity of thisArrayListinstance, if necessary, to ensure that it can hold at least the number of elements specified by the minimum capacity argument.booleanChained addition of elementsfluentAddAll(Collection<?> c) fluentRemove(int index) fluentRemoveAll(Collection<?> c) voidget(int index) Returns the element at the specified position in this list.getBigDecimal(int index) Returns theBigDecimalat the specified location in thisDataList.getBigInteger(int index) Returns theBigIntegerat the specified location in thisDataList.getBoolean(int index) booleangetBooleanValue(int index) Returns a boolean value at the specified location in thisDataList.getByte(int index) bytegetByteValue(int index) Returns a byte value at the specified location in thisDataList.getDataList(int index) getDataMap(int index) getDate(int index) getDouble(int index) doublegetDoubleValue(int index) Returns a double value at the specified location in thisDataList.getFloat(int index) floatgetFloatValue(int index) Returns a float value at the specified location in thisDataList.java.time.InstantgetInstant(int index) Returns theInstantat the specified location in thisDataList.getInteger(int index) intgetIntValue(int index) Returns an int value at the specified location in thisDataList.getLong(int index) longgetLongValue(int index) Returns a long value at the specified location in thisDataList.<T> T<T> T<T> TgetObject(int index, java.util.function.Function<com.alibaba.fastjson2.JSONObject, T> creator) getShort(int index) shortgetShortValue(int index) Returns a short value at the specified location in thisDataList.getString(int index) inthashCode()intReturns the index of the first occurrence of the specified element in this list, or -1 if this list does not contain the element.booleanisEmpty()Returnstrueif this list contains no elements.booleanisValid(com.alibaba.fastjson2.schema.JSONSchema schema) iterator()Returns an iterator over the elements in this list in proper sequence.intReturns the index of the last occurrence of the specified element in this list, or -1 if this list does not contain the element.Returns a list iterator over the elements in this list (in proper sequence).listIterator(int index) Returns a list iterator over the elements in this list (in proper sequence), starting at the specified position in the list.java.util.stream.Stream<Object>Returns a possibly parallelStreamwith this collection as its source.remove(int index) Removes the element at the specified position in this list.booleanRemoves the first occurrence of the specified element from this list, if it is present.booleanremoveAll(Collection<?> c) Removes from this list all of its elements that are contained in the specified collection.booleanprotected voidremoveRange(int fromIndex, int toIndex) Removes from this list all of the elements whose index is betweenfromIndex, inclusive, andtoIndex, exclusive.voidreplaceAll(java.util.function.UnaryOperator<Object> operator) booleanretainAll(Collection<?> c) Retains only the elements in this list that are contained in the specified collection.Replaces the element at the specified position with the specified elementintsize()Returns the number of elements in this list.voidsort(Comparator<? super Object> c) Creates a late-binding and fail-fastSpliteratorover the elements in this list.java.util.stream.Stream<Object>stream()Returns a sequentialStreamwith this collection as its source.subList(int fromIndex, int toIndex) Returns a view of the portion of this list between the specifiedfromIndex, inclusive, andtoIndex, exclusive.<T> T<T> TConvert thisDataListto the specified ObjectObject[]toArray()Returns an array containing all of the elements in this list in proper sequence (from first to last element).<T> T[]Convert all the members of thisDataListinto the specified Object.<T> T[]toArray(java.util.function.IntFunction<T[]> generator) Returns an array containing all of the elements in this collection, using the providedgeneratorfunction to allocate the returned array.<T> T[]toArray(T[] a) Returns an array containing all of the elements in this list in proper sequence (from first to last element); the runtime type of the returned array is that of the specified array.<T> List<T>toJavaList(Class<T> clazz, com.alibaba.fastjson2.JSONReader.Feature... features) 已过时。<T> TtoJavaObject(Type type) 已过时。since 2.0.4, please useto(Type)byte[]toJSONBBytes(com.alibaba.fastjson2.JSONWriter.Feature... features) Serialize to JSONB bytestoJSONString(com.alibaba.fastjson2.JSONWriter.Feature... features) Serialize to JSONString<T> List<T>Convert all the members of thisDataListinto the specified Object.toString()toString(com.alibaba.fastjson2.JSONWriter.Feature... features) Serialize to JSONStringvoidTrims the capacity of thisArrayListinstance to be the list's current size.从类继承的方法 com.alibaba.fastjson2.JSONArray
getJSONArray, getJSONObject, of, of, of, of, parseArray
-
构造器详细资料
-
DataList
public DataList()default -
DataList
public DataList(int initialCapacity) - 参数:
initialCapacity- the initial capacity of theDataList- 抛出:
IllegalArgumentException- If the specified initial capacity is negative
-
DataList
- 参数:
collection- the collection whose elements are to be placed into thisDataList- 抛出:
NullPointerException- If the specified collection is null
-
DataList
- 参数:
items- the array whose elements are to be placed into thisDataList- 抛出:
NullPointerException- If the specified items is null
-
-
方法详细资料
-
set
Replaces the element at the specified position with the specified elementDataList array = new DataList(); array.add(-1); // [-1] array.add(2); // [-1,2] array.set(0, 1); // [1,2] array.set(4, 3); // [1,2,null,null,3] array.set(-1, -1); // [1,2,null,null,-1] array.set(-2, -2); // [1,2,null,-2,-1] array.set(-6, -6); // [-6,1,2,null,-2,-1] -
getDataList
- 参数:
index- index of the element to return- 返回:
DataListor null- 抛出:
IndexOutOfBoundsException- if the index is out of range(index < 0 || index >= size())
-
getDataMap
- 参数:
index- index of the element to return- 返回:
DataMapor null- 抛出:
IndexOutOfBoundsException- if the index is out of range(index < 0 || index >= size())
-
getString
- 覆盖:
getString在类中com.alibaba.fastjson2.JSONArray- 参数:
index- index of the element to return- 返回:
Stringor null- 抛出:
IndexOutOfBoundsException- if the index is out of range(index < 0 || index >= size())
-
getDouble
- 覆盖:
getDouble在类中com.alibaba.fastjson2.JSONArray- 参数:
index- index of the element to return- 返回:
Doubleor null- 抛出:
NumberFormatException- If the value of get isStringand it contains no parsable doublecom.alibaba.fastjson2.JSONException- Unsupported type conversion toDoubleIndexOutOfBoundsException- if the index is out of range(index < 0 || index >= size())
-
getDoubleValue
public double getDoubleValue(int index) Returns a double value at the specified location in thisDataList.- 覆盖:
getDoubleValue在类中com.alibaba.fastjson2.JSONArray- 参数:
index- index of the element to return- 返回:
- double
- 抛出:
NumberFormatException- If the value of get isStringand it contains no parsable doublecom.alibaba.fastjson2.JSONException- Unsupported type conversion to double valueIndexOutOfBoundsException- if the index is out of range(index < 0 || index >= size())
-
getFloat
- 覆盖:
getFloat在类中com.alibaba.fastjson2.JSONArray- 参数:
index- index of the element to return- 返回:
Floator null- 抛出:
NumberFormatException- If the value of get isStringand it contains no parsable floatcom.alibaba.fastjson2.JSONException- Unsupported type conversion toFloatIndexOutOfBoundsException- if the index is out of range(index < 0 || index >= size())
-
getFloatValue
public float getFloatValue(int index) Returns a float value at the specified location in thisDataList.- 覆盖:
getFloatValue在类中com.alibaba.fastjson2.JSONArray- 参数:
index- index of the element to return- 返回:
- float
- 抛出:
NumberFormatException- If the value of get isStringand it contains no parsable floatcom.alibaba.fastjson2.JSONException- Unsupported type conversion to float valueIndexOutOfBoundsException- if the index is out of range(index < 0 || index >= size())
-
getLong
- 覆盖:
getLong在类中com.alibaba.fastjson2.JSONArray- 参数:
index- index of the element to return- 返回:
Longor null- 抛出:
NumberFormatException- If the value of get isStringand it contains no parsable longcom.alibaba.fastjson2.JSONException- Unsupported type conversion toLongIndexOutOfBoundsException- if the index is out of range(index < 0 || index >= size())
-
getLongValue
public long getLongValue(int index) Returns a long value at the specified location in thisDataList.- 覆盖:
getLongValue在类中com.alibaba.fastjson2.JSONArray- 参数:
index- index of the element to return- 返回:
- long
- 抛出:
NumberFormatException- If the value of get isStringand it contains no parsable longcom.alibaba.fastjson2.JSONException- Unsupported type conversion to long valueIndexOutOfBoundsException- if the index is out of range(index < 0 || index >= size())
-
getInteger
- 覆盖:
getInteger在类中com.alibaba.fastjson2.JSONArray- 参数:
index- index of the element to return- 返回:
Integeror null- 抛出:
NumberFormatException- If the value of get isStringand it contains no parsable intcom.alibaba.fastjson2.JSONException- Unsupported type conversion toIntegerIndexOutOfBoundsException- if the index is out of range(index < 0 || index >= size())
-
getIntValue
public int getIntValue(int index) Returns an int value at the specified location in thisDataList.- 覆盖:
getIntValue在类中com.alibaba.fastjson2.JSONArray- 参数:
index- index of the element to return- 返回:
- int
- 抛出:
NumberFormatException- If the value of get isStringand it contains no parsable intcom.alibaba.fastjson2.JSONException- Unsupported type conversion to int valueIndexOutOfBoundsException- if the index is out of range(index < 0 || index >= size())
-
getShort
- 覆盖:
getShort在类中com.alibaba.fastjson2.JSONArray- 参数:
index- index of the element to return- 返回:
Shortor null- 抛出:
NumberFormatException- If the value of get isStringand it contains no parsable shortcom.alibaba.fastjson2.JSONException- Unsupported type conversion toShortIndexOutOfBoundsException- if the index is out of range(index < 0 || index >= size())
-
getShortValue
public short getShortValue(int index) Returns a short value at the specified location in thisDataList.- 覆盖:
getShortValue在类中com.alibaba.fastjson2.JSONArray- 参数:
index- index of the element to return- 返回:
- short
- 抛出:
NumberFormatException- If the value of get isStringand it contains no parsable shortcom.alibaba.fastjson2.JSONException- Unsupported type conversion to short valueIndexOutOfBoundsException- if the index is out of range(index < 0 || index >= size())
-
getByte
- 覆盖:
getByte在类中com.alibaba.fastjson2.JSONArray- 参数:
index- index of the element to return- 返回:
Byteor null- 抛出:
NumberFormatException- If the value of get isStringand it contains no parsable bytecom.alibaba.fastjson2.JSONException- Unsupported type conversion toByteIndexOutOfBoundsException- if the index is out of range(index < 0 || index >= size())
-
getByteValue
public byte getByteValue(int index) Returns a byte value at the specified location in thisDataList.- 覆盖:
getByteValue在类中com.alibaba.fastjson2.JSONArray- 参数:
index- index of the element to return- 返回:
- byte
- 抛出:
NumberFormatException- If the value of get isStringand it contains no parsable bytecom.alibaba.fastjson2.JSONException- Unsupported type conversion to byte valueIndexOutOfBoundsException- if the index is out of range(index < 0 || index >= size())
-
getBoolean
- 覆盖:
getBoolean在类中com.alibaba.fastjson2.JSONArray- 参数:
index- index of the element to return- 返回:
Booleanor null- 抛出:
com.alibaba.fastjson2.JSONException- Unsupported type conversion toBooleanIndexOutOfBoundsException- if the index is out of range(index < 0 || index >= size())
-
getBooleanValue
public boolean getBooleanValue(int index) Returns a boolean value at the specified location in thisDataList.- 覆盖:
getBooleanValue在类中com.alibaba.fastjson2.JSONArray- 参数:
index- index of the element to return- 返回:
- boolean
- 抛出:
com.alibaba.fastjson2.JSONException- Unsupported type conversion to boolean valueIndexOutOfBoundsException- if the index is out of range(index < 0 || index >= size())
-
getBigInteger
Returns theBigIntegerat the specified location in thisDataList.- 覆盖:
getBigInteger在类中com.alibaba.fastjson2.JSONArray- 参数:
index- index of the element to return- 返回:
BigIntegeror null- 抛出:
IndexOutOfBoundsException- if the index is out of range(index < 0 || index >= size())com.alibaba.fastjson2.JSONException- Unsupported type conversion toBigIntegerNumberFormatException- If the value of get isStringand it is not a valid representation ofBigInteger
-
getBigDecimal
Returns theBigDecimalat the specified location in thisDataList.- 覆盖:
getBigDecimal在类中com.alibaba.fastjson2.JSONArray- 参数:
index- index of the element to return- 返回:
BigDecimalor null- 抛出:
IndexOutOfBoundsException- if the index is out of range(index < 0 || index >= size())com.alibaba.fastjson2.JSONException- Unsupported type conversion toBigDecimalNumberFormatException- If the value of get isStringand it is not a valid representation ofBigDecimal
-
getDate
- 覆盖:
getDate在类中com.alibaba.fastjson2.JSONArray- 参数:
index- index of the element to return- 返回:
Dateor null- 抛出:
IndexOutOfBoundsException- if the index is out of range(index < 0 || index >= size())
-
getInstant
public java.time.Instant getInstant(int index) Returns theInstantat the specified location in thisDataList.- 覆盖:
getInstant在类中com.alibaba.fastjson2.JSONArray- 参数:
index- index of the element to return- 返回:
Instantor null- 抛出:
IndexOutOfBoundsException- if the index is out of range(index < 0 || index >= size())
-
toString
Serialize to JSONString- 覆盖:
toString在类中com.alibaba.fastjson2.JSONArray- 参数:
features- features to be enabled in serialization- 返回:
- JSON
String
-
toJSONString
Serialize to JSONString- 覆盖:
toJSONString在类中com.alibaba.fastjson2.JSONArray- 参数:
features- features to be enabled in serialization- 返回:
- JSON
String
-
toJSONBBytes
public byte[] toJSONBBytes(com.alibaba.fastjson2.JSONWriter.Feature... features) Serialize to JSONB bytes- 覆盖:
toJSONBBytes在类中com.alibaba.fastjson2.JSONArray- 参数:
features- features to be enabled in serialization- 返回:
- JSONB bytes
-
to
Convert thisDataListto the specified ObjectDataList array = ... List<User> users = array.to(new TypeReference<ArrayList<User>>(){}.getType());- 覆盖:
to在类中com.alibaba.fastjson2.JSONArray- 参数:
type- specify theTypeto be converted- 从以下版本开始:
- 2.0.4
-
to
- 覆盖:
to在类中com.alibaba.fastjson2.JSONArray- 类型参数:
T- 泛型- 参数:
type- 类型- 返回:
- T
-
toJavaObject
已过时。since 2.0.4, please useto(Type)Convert thisDataListto the specified Object- 覆盖:
toJavaObject在类中com.alibaba.fastjson2.JSONArray- 参数:
type- specify theTypeto be converted
-
toList
Convert all the members of thisDataListinto the specified Object.String json = "[{\"id\": 1, \"name\": \"fastjson\"}, {\"id\": 2, \"name\": \"fastjson2\"}]"; DataList array = JSON.parseArray(json); List<User> users = array.toList(User.class);- 覆盖:
toList在类中com.alibaba.fastjson2.JSONArray- 参数:
itemClass- specify theClass<T>to be convertedfeatures- features to be enabled in parsing- 从以下版本开始:
- 2.0.4
-
toArray
Convert all the members of thisDataListinto the specified Object.String json = "[{\"id\": 1, \"name\": \"fastjson\"}, {\"id\": 2, \"name\": \"fastjson2\"}]"; DataList array = JSON.parseArray(json); List<User> users = array.toList(User.class);- 覆盖:
toArray在类中com.alibaba.fastjson2.JSONArray- 参数:
itemClass- specify theClass<T>to be convertedfeatures- features to be enabled in parsing- 从以下版本开始:
- 2.0.4
-
toJavaList
已过时。since 2.0.4, please usetoList(Class, JSONReader.Feature...)Convert all the members of thisDataListinto the specified Object.- 覆盖:
toJavaList在类中com.alibaba.fastjson2.JSONArray- 参数:
clazz- specify theClass<T>to be convertedfeatures- features to be enabled in parsing
-
getObject
Returns the result of theTypeconverter conversion of the element at the specified position in thisDataList.DataList array = ... User user = array.getObject(0, TypeReference<HashMap<String ,User>>(){}.getType());- 覆盖:
getObject在类中com.alibaba.fastjson2.JSONArray- 参数:
index- index of the element to returntype- specify theTypeto be convertedfeatures-- 返回:
<T>or null- 抛出:
com.alibaba.fastjson2.JSONException- If no suitable conversion method is foundIndexOutOfBoundsException- if the index is out of range(index < 0 || index >= size())
-
getObject
public <T> T getObject(int index, Class<T> type, com.alibaba.fastjson2.JSONReader.Feature... features) Returns the result of theTypeconverter conversion of the element at the specified position in thisDataList.User user = DataList.getObject(0, User.class);- 覆盖:
getObject在类中com.alibaba.fastjson2.JSONArray- 参数:
index- index of the element to returntype- specify theClassto be convertedfeatures-- 返回:
<T>or null- 抛出:
com.alibaba.fastjson2.JSONException- If no suitable conversion method is foundIndexOutOfBoundsException- if the index is out of range(index < 0 || index >= size())
-
getObject
public <T> T getObject(int index, java.util.function.Function<com.alibaba.fastjson2.JSONObject, T> creator) - 覆盖:
getObject在类中com.alibaba.fastjson2.JSONArray- 参数:
index-creator-- 从以下版本开始:
- 2.0.3
-
fluentAdd
Chained addition of elementsDataList array = new DataList().fluentAdd(1).fluentAdd(2).fluentAdd(3);
- 覆盖:
fluentAdd在类中com.alibaba.fastjson2.JSONArray- 参数:
element- element to be appended to this list
-
fluentClear
- 覆盖:
fluentClear在类中com.alibaba.fastjson2.JSONArray- 从以下版本开始:
- 2.0.3
-
fluentRemove
- 覆盖:
fluentRemove在类中com.alibaba.fastjson2.JSONArray- 参数:
index-- 从以下版本开始:
- 2.0.3
-
fluentSet
- 覆盖:
fluentSet在类中com.alibaba.fastjson2.JSONArray- 参数:
index-element-- 从以下版本开始:
- 2.0.3
-
fluentRemove
- 覆盖:
fluentRemove在类中com.alibaba.fastjson2.JSONArray- 参数:
o-- 从以下版本开始:
- 2.0.3
-
fluentRemoveAll
- 覆盖:
fluentRemoveAll在类中com.alibaba.fastjson2.JSONArray- 参数:
c-- 从以下版本开始:
- 2.0.3
-
fluentAddAll
- 覆盖:
fluentAddAll在类中com.alibaba.fastjson2.JSONArray- 参数:
c-- 从以下版本开始:
- 2.0.3
-
isValid
public boolean isValid(com.alibaba.fastjson2.schema.JSONSchema schema) - 覆盖:
isValid在类中com.alibaba.fastjson2.JSONArray- 参数:
schema-- 从以下版本开始:
- 2.0.3
-
trimToSize
public void trimToSize()Trims the capacity of thisArrayListinstance to be the list's current size. An application can use this operation to minimize the storage of anArrayListinstance.- 覆盖:
trimToSize在类中ArrayList<Object>
-
ensureCapacity
public void ensureCapacity(int minCapacity) Increases the capacity of thisArrayListinstance, if necessary, to ensure that it can hold at least the number of elements specified by the minimum capacity argument.- 覆盖:
ensureCapacity在类中ArrayList<Object>- 参数:
minCapacity- the desired minimum capacity
-
size
public int size()Returns the number of elements in this list. -
isEmpty
public boolean isEmpty()Returnstrueif this list contains no elements. -
contains
Returnstrueif this list contains the specified element. More formally, returnstrueif and only if this list contains at least one elementesuch thatObjects.equals(o, e). -
indexOf
Returns the index of the first occurrence of the specified element in this list, or -1 if this list does not contain the element. More formally, returns the lowest indexisuch thatObjects.equals(o, get(i)), or -1 if there is no such index. -
lastIndexOf
Returns the index of the last occurrence of the specified element in this list, or -1 if this list does not contain the element. More formally, returns the highest indexisuch thatObjects.equals(o, get(i)), or -1 if there is no such index.- 指定者:
lastIndexOf在接口中List<Object>- 覆盖:
lastIndexOf在类中ArrayList<Object>- 参数:
o-
-
toArray
Returns an array containing all of the elements in this list in proper sequence (from first to last element).The returned array will be "safe" in that no references to it are maintained by this list. (In other words, this method must allocate a new array). The caller is thus free to modify the returned array.
This method acts as bridge between array-based and collection-based APIs.
-
toArray
public <T> T[] toArray(T[] a) Returns an array containing all of the elements in this list in proper sequence (from first to last element); the runtime type of the returned array is that of the specified array. If the list fits in the specified array, it is returned therein. Otherwise, a new array is allocated with the runtime type of the specified array and the size of this list.If the list fits in the specified array with room to spare (i.e., the array has more elements than the list), the element in the array immediately following the end of the collection is set to
null. (This is useful in determining the length of the list only if the caller knows that the list does not contain any null elements.)- 指定者:
toArray在接口中Collection<Object>- 指定者:
toArray在接口中List<Object>- 覆盖:
toArray在类中ArrayList<Object>- 参数:
a- the array into which the elements of the list are to be stored, if it is big enough; otherwise, a new array of the same runtime type is allocated for this purpose.- 返回:
- an array containing the elements of the list
- 抛出:
ArrayStoreException- if the runtime type of the specified array is not a supertype of the runtime type of every element in this listNullPointerException- if the specified array is null
-
get
Returns the element at the specified position in this list. -
add
Appends the specified element to the end of this list.- 指定者:
add在接口中Collection<Object>- 指定者:
add在接口中List<Object>- 覆盖:
add在类中ArrayList<Object>- 参数:
o- element to be appended to this list- 返回:
true(as specified byCollection.add(E))
-
add
Inserts the specified element at the specified position in this list. Shifts the element currently at that position (if any) and any subsequent elements to the right (adds one to their indices). -
remove
Removes the element at the specified position in this list. Shifts any subsequent elements to the left (subtracts one from their indices). -
equals
-
hashCode
public int hashCode() -
remove
Removes the first occurrence of the specified element from this list, if it is present. If the list does not contain the element, it is unchanged. More formally, removes the element with the lowest indexisuch thatObjects.equals(o, get(i))(if such an element exists). Returnstrueif this list contained the specified element (or equivalently, if this list changed as a result of the call). -
clear
public void clear()Removes all of the elements from this list. The list will be empty after this call returns. -
addAll
Appends all of the elements in the specified collection to the end of this list, in the order that they are returned by the specified collection's Iterator. The behavior of this operation is undefined if the specified collection is modified while the operation is in progress. (This implies that the behavior of this call is undefined if the specified collection is this list, and this list is nonempty.)- 指定者:
addAll在接口中Collection<Object>- 指定者:
addAll在接口中List<Object>- 覆盖:
addAll在类中ArrayList<Object>- 参数:
c- collection containing elements to be added to this list- 返回:
trueif this list changed as a result of the call- 抛出:
NullPointerException- if the specified collection is null
-
addAll
Inserts all of the elements in the specified collection into this list, starting at the specified position. Shifts the element currently at that position (if any) and any subsequent elements to the right (increases their indices). The new elements will appear in the list in the order that they are returned by the specified collection's iterator.- 指定者:
addAll在接口中List<Object>- 覆盖:
addAll在类中ArrayList<Object>- 参数:
index- index at which to insert the first element from the specified collectionc- collection containing elements to be added to this list- 返回:
trueif this list changed as a result of the call- 抛出:
IndexOutOfBoundsExceptionNullPointerException- if the specified collection is null
-
removeRange
protected void removeRange(int fromIndex, int toIndex) Removes from this list all of the elements whose index is betweenfromIndex, inclusive, andtoIndex, exclusive. Shifts any succeeding elements to the left (reduces their index). This call shortens the list by(toIndex - fromIndex)elements. (IftoIndex==fromIndex, this operation has no effect.)- 覆盖:
removeRange在类中ArrayList<Object>- 参数:
fromIndex-toIndex-- 抛出:
IndexOutOfBoundsException- iffromIndexortoIndexis out of range (fromIndex < 0 || toIndex > size() || toIndex < fromIndex)
-
removeAll
Removes from this list all of its elements that are contained in the specified collection.- 指定者:
removeAll在接口中Collection<Object>- 指定者:
removeAll在接口中List<Object>- 覆盖:
removeAll在类中ArrayList<Object>- 参数:
c- collection containing elements to be removed from this list- 返回:
trueif this list changed as a result of the call- 抛出:
ClassCastException- if the class of an element of this list is incompatible with the specified collection (optional)NullPointerException- if this list contains a null element and the specified collection does not permit null elements (optional), or if the specified collection is null- 另请参阅:
-
retainAll
Retains only the elements in this list that are contained in the specified collection. In other words, removes from this list all of its elements that are not contained in the specified collection.- 指定者:
retainAll在接口中Collection<Object>- 指定者:
retainAll在接口中List<Object>- 覆盖:
retainAll在类中ArrayList<Object>- 参数:
c- collection containing elements to be retained in this list- 返回:
trueif this list changed as a result of the call- 抛出:
ClassCastException- if the class of an element of this list is incompatible with the specified collection (optional)NullPointerException- if this list contains a null element and the specified collection does not permit null elements (optional), or if the specified collection is null- 另请参阅:
-
listIterator
Returns a list iterator over the elements in this list (in proper sequence), starting at the specified position in the list. The specified index indicates the first element that would be returned by an initial call tonext. An initial call topreviouswould return the element with the specified index minus one.The returned list iterator is fail-fast.
- 指定者:
listIterator在接口中List<Object>- 覆盖:
listIterator在类中ArrayList<Object>- 参数:
index-- 抛出:
IndexOutOfBoundsException
-
listIterator
Returns a list iterator over the elements in this list (in proper sequence).The returned list iterator is fail-fast.
- 指定者:
listIterator在接口中List<Object>- 覆盖:
listIterator在类中ArrayList<Object>- 另请参阅:
-
iterator
Returns an iterator over the elements in this list in proper sequence.The returned iterator is fail-fast.
-
subList
Returns a view of the portion of this list between the specifiedfromIndex, inclusive, andtoIndex, exclusive. (IffromIndexandtoIndexare equal, the returned list is empty.) The returned list is backed by this list, so non-structural changes in the returned list are reflected in this list, and vice-versa. The returned list supports all of the optional list operations.This method eliminates the need for explicit range operations (of the sort that commonly exist for arrays). Any operation that expects a list can be used as a range operation by passing a subList view instead of a whole list. For example, the following idiom removes a range of elements from a list:
list.subList(from, to).clear();Similar idioms may be constructed forindexOf(Object)andlastIndexOf(Object), and all of the algorithms in theCollectionsclass can be applied to a subList.The semantics of the list returned by this method become undefined if the backing list (i.e., this list) is structurally modified in any way other than via the returned list. (Structural modifications are those that change the size of this list, or otherwise perturb it in such a fashion that iterations in progress may yield incorrect results.)
- 指定者:
subList在接口中List<Object>- 覆盖:
subList在类中ArrayList<Object>- 参数:
fromIndex-toIndex-- 抛出:
IndexOutOfBoundsExceptionIllegalArgumentException
-
forEach
-
spliterator
Creates a late-binding and fail-fastSpliteratorover the elements in this list.The
SpliteratorreportsSpliterator.SIZED,Spliterator.SUBSIZED, andSpliterator.ORDERED. Overriding implementations should document the reporting of additional characteristic values.- 指定者:
spliterator在接口中Collection<Object>- 指定者:
spliterator在接口中Iterable<Object>- 指定者:
spliterator在接口中List<Object>- 覆盖:
spliterator在类中ArrayList<Object>- 返回:
- a
Spliteratorover the elements in this list - 从以下版本开始:
- 1.8
-
removeIf
- 指定者:
removeIf在接口中Collection<Object>- 覆盖:
removeIf在类中ArrayList<Object>- 参数:
filter-- 抛出:
NullPointerException
-
replaceAll
- 指定者:
replaceAll在接口中List<Object>- 覆盖:
replaceAll在类中ArrayList<Object>- 参数:
operator- the operator to apply to each element
-
sort
-
containsAll
- 指定者:
containsAll在接口中Collection<Object>- 指定者:
containsAll在接口中List<Object>- 覆盖:
containsAll在类中AbstractCollection<Object>- 参数:
c-- 抛出:
ClassCastExceptionNullPointerException- 另请参阅:
-
toArray
public <T> T[] toArray(java.util.function.IntFunction<T[]> generator) Returns an array containing all of the elements in this collection, using the providedgeneratorfunction to allocate the returned array.If this collection makes any guarantees as to what order its elements are returned by its iterator, this method must return the elements in the same order.
- 指定者:
toArray在接口中Collection<Object>- 参数:
generator- a function which produces a new array of the desired type and the provided length- 返回:
- an array containing all of the elements in this collection
- 抛出:
ArrayStoreException- if the runtime type of any element in this collection is not assignable to the runtime component type of the generated arrayNullPointerException- if the generator function is null- 从以下版本开始:
- 11
-
stream
Returns a sequentialStreamwith this collection as its source.This method should be overridden when the
spliterator()method cannot return a spliterator that isIMMUTABLE,CONCURRENT, or late-binding. (Seespliterator()for details.)- 指定者:
stream在接口中Collection<Object>- 返回:
- a sequential
Streamover the elements in this collection - 从以下版本开始:
- 1.8
-
parallelStream
Returns a possibly parallelStreamwith this collection as its source. It is allowable for this method to return a sequential stream.This method should be overridden when the
spliterator()method cannot return a spliterator that isIMMUTABLE,CONCURRENT, or late-binding. (Seespliterator()for details.)- 指定者:
parallelStream在接口中Collection<Object>- 返回:
- a possibly parallel
Streamover the elements in this collection - 从以下版本开始:
- 1.8
-
toString
- 覆盖:
toString在类中com.alibaba.fastjson2.JSONArray
-
clone
- 覆盖:
clone在类中com.alibaba.fastjson2.JSONArray
-
toList(Class, JSONReader.Feature...)