Вот код:
Код: Выделить всё
public class Utility {
ArrayList list = new ArrayList();
// Insert the code here.
public Utility() {
list = new ArrayList();
}
public Utility(List list) {
this.list = new ArrayList(list);
}
public int linearSearch(T item) {
int position = -1;
for (int i = 0; i < list.size(); i++) {
if (item.compareTo(list.get(i)) == 0) {
position = i;
break;
}
}
return position;
}
public void mergeList(List list) {
for (T obj: this.list)
list.add(obj);
}
public boolean containList(List list) {
if (this.list.containsAll(list)) {
this.list = new ArrayList();
for (T obj: list)
this.list.add(obj);
return true;
}
else
return false;
}
public void removeZero(List myList) {
for (int i = 0; i < myList.size(); i++) {
if (MyInteger.isZero(myList.get(i))) {
myList.remove(i);
i--;
}
}
}
}
java: несовместимые типы: T невозможно преобразовать в T
Подробнее здесь: https://stackoverflow.com/questions/792 ... erted-to-t
Мобильная версия