문제

In an app I am working on, I want to return an Iterable or a subclass of Iterable and pass in the values directly. So I'm trying to do something like this:

private CustomClass valueOne;
private CustomClass valueTwo;

public Iterable<? extends CustomClass> children() {
    return Array.asList(valueOne, valueTwo);
}

The thing is, asList doesn't seem to work. Is there anything like this that I could use? I've been searching but I can't seem to find anything that works in my case.

도움이 되었습니까?

해결책

change

Array.asList

to

Arrays.asList

asList method is available on Arrays class not in Array

List<CustomClass> list= Arrays.asList(new CustomClass[]{valueOne,valueTwo});
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top