mirror of
https://github.com/corda/corda.git
synced 2025-01-06 21:18:46 +00:00
make ArrayList.set() do bounds checking
This commit is contained in:
parent
a6a1f8ba98
commit
4f047ded8c
@ -108,12 +108,13 @@ public class ArrayList<T> implements List<T> {
|
||||
}
|
||||
|
||||
public T set(int index, T element) {
|
||||
if (index >= size) {
|
||||
resize(index+1);
|
||||
if (index >= 0 && index < size) {
|
||||
Object oldValue = array[index];
|
||||
array[index] = element;
|
||||
return (T) oldValue;
|
||||
} else {
|
||||
throw new IndexOutOfBoundsException(index + " not in [0, " + size + ")");
|
||||
}
|
||||
Object oldValue = array[index];
|
||||
array[index] = element;
|
||||
return (T) oldValue;
|
||||
}
|
||||
|
||||
public T remove(int index) {
|
||||
|
Loading…
Reference in New Issue
Block a user