I've got a method which goes like this -
public IntSequence subSequence(int index, int size) {
//IntSequence is an interface and currently this thing is inside a class that's
//implementing it
ArrayList<Integer> valuelist = new ArrayList<>();
for(int i = a1; i <= a2 + a1; i++)
{
if((a1 + a2) <= a.length)
valuelist.add(a[i]);
}
return valuelist;
}
My problem here is, I just want to return a sequence of integers however what I am returning here is an ArrayList and the compiler says cannot convert from type IntSequence to ArrayList.
(I'm not allowed to change the parameters of the method)
Thanks for acknowledging the problem!
EDIT :
This is my IntSequence interface -
public interface IntSequence {
int length();
int get(int index);
void set(int index, int value);
IntSequence subSequence(int index, int size);
}
IntSequence, well, a class that implements it, right?IntSequenceand defines a constructor with anArrayList<Integer>parameter. But it's hard to give you any more help without seeing whatIntSequencelooks like.