Question

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.

Was it helpful?

Solution

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});
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top