add
Добавлено: 10 сен 2014, 15:39
void java.util.ArrayList.add(int index, String object)
Здравствуйте!
Подскажите пожалуйста , за что конктектно отвечает индекс метода add ? Я понимаю что он отвечает за расположения объекта , но когда я его инкреминирую , то вылетает ошибка, связанная с неправельным индексом . А без инкремента все нормально logoname.add(0,SaySee3);
Может он используется для многомерных массивов ?
Я инкреминирую так :
static int i=0;
logoname.add(i,SaySee3);
i++;
------------------------------
Inserts the specified object into this ArrayList at the specified location. The object is inserted before any previous element at the specified location. If the location is equal to the size of this ArrayList, the object is added at the end.
Overrides: add(...) in AbstractList
Parameters:
index the index at which to insert the object.
object the object to add.
-----------------------------
-----------------------------
@Override public void add(int index, E object) {
Object[] a = array;
int s = size;
if (index > s || index < 0) {
throwIndexOutOfBoundsException(index, s);
}
---------------------------
Здравствуйте!
Подскажите пожалуйста , за что конктектно отвечает индекс метода add ? Я понимаю что он отвечает за расположения объекта , но когда я его инкреминирую , то вылетает ошибка, связанная с неправельным индексом . А без инкремента все нормально logoname.add(0,SaySee3);
Может он используется для многомерных массивов ?
Я инкреминирую так :
static int i=0;
logoname.add(i,SaySee3);
i++;
------------------------------
Inserts the specified object into this ArrayList at the specified location. The object is inserted before any previous element at the specified location. If the location is equal to the size of this ArrayList, the object is added at the end.
Overrides: add(...) in AbstractList
Parameters:
index the index at which to insert the object.
object the object to add.
-----------------------------
-----------------------------
@Override public void add(int index, E object) {
Object[] a = array;
int s = size;
if (index > s || index < 0) {
throwIndexOutOfBoundsException(index, s);
}
---------------------------