Mam klase z kontrukorami
public class XList<T> {
Collection<T> list;
public XList(Collection<T> list){
this.list = list;
}
@SafeVarargs//Ostrzezenie - jak sie tego pozbyc
public XList(T...args){
list = new ArrayList<T>();
for(int i=0; i<args.length; i++){
list.add(args[i]);
}
}
@SafeVarargs//Ostrzezenie - jak sie tego pozbyc
public static<T> XList<T> of(T...args){
return new XList<T>(args);
}
public static<T> XList<T> of(Collection<T> list){
return new XList<T>(list);
}
public static<T> XList<T> charsOf(String napis){
char[] tab = napis.toCharArray();
List<Character> list = new ArrayList<>();
for(int i=0; i<tab.length; i++){
list.add(tab[i]);
}
return new XList(list); //Type safety: The expression of type XList needs unchecked conversion to conform to XList<T>
}
}
Zadanie jest nastepujace
Stworzyć klasę XList, dostarczającą dodatkowych możliwości tworzenia list i operowania na nich.
W klasie powinny znaleźć się odpowiednie konstruktory oraz statyczne metody of, umożliwiające tworzenie obiektów XList z innych kolekcji, tablic oraz argumentów podawanych przez przecinki.
Dodatkowo pomocnicze metody do tworzenia xlist z napisów:
ofChars(napis) - zwraca x-listę znaków napisu,
Wszystko dziala ale chcailbym sie pozbyc ostrzezen