Conversation
| # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml | ||
| hs_err_pid* | ||
| /out/ | ||
| /.idea/ |
There was a problem hiding this comment.
Отлично, что дополнил!
Для полноты нужно еще *.iml добавить.
| return null; | ||
| } | ||
|
|
||
| public static void main(String [] args){ |
There was a problem hiding this comment.
main лучше выносить в отдельный класс.
| } | ||
|
|
||
| public static void main(String [] args){ | ||
| DimbossArrayList<Integer> testList=new DimbossArrayList<>(); |
There was a problem hiding this comment.
Все еще проблемы с форматированием.
Не забывай про ctrl + alt + L.
| } | ||
|
|
||
| @Override | ||
| public <E1> E1[] toArray(E1[] a) { |
There was a problem hiding this comment.
А зачем еще один дженерик ввел? У тебя же есть общий для всего класса - E
|
|
||
| private E[] listArr; | ||
| private int size; | ||
| private static final int DEFAULT_SIZE=10; |
| public boolean add(E t) { | ||
| add(size, t); | ||
| return true; | ||
| } |
There was a problem hiding this comment.
Я бы предложил методы группировать пологичнее. Например, помещать перегруженные add рядом друг с другом. remove тоже рядом.
| public boolean remove(Object o) { | ||
| int i; | ||
| for (i = 0; i < size; i++) | ||
| if (listArr[i] == o) |
There was a problem hiding this comment.
А почему через == сравниваешь, а не через equals?
| return null; | ||
| } | ||
|
|
||
| public static void main(String [] args){ |
There was a problem hiding this comment.
Не провел сравнение производительности своей реализации ArrayList со стандартной
| @Override | ||
| public int indexOf(Object o) { | ||
| for (int i = 0; i < size; i++) | ||
| if (listArr[i] == o) |
There was a problem hiding this comment.
А почему через == сравниваешь, а не через equals?
| } | ||
|
|
||
| @Override | ||
| public boolean remove(Object o) { |
There was a problem hiding this comment.
Слушай, а почему бы тебе не осуществлять здесь поиск по объекту с определением индекса, а потом вызвать remove по индексу? Переиспользуешь код почти нахаляву.
No description provided.