I have an iterable object in java. Can I return an array in the iterator method?
anonymous
2012-10-27 23:45:51 UTC
I got an object in java which contains an array and a tree. I want to iterate this object using the array.
In other words, I want to return the array as the iterator object. is this possible? If yes, how can i do it?
Three answers:
godfatherofsoul
2012-10-28 10:38:00 UTC
The best thing to do is return the array wrapped in an immutable Collection (to prevent the caller for changing it). Then, let the caller access the iterator on your Collection object. It's not good form to return an iterator.
one way is to maintain a huge determination as area of the class. then you definately increment while pushing, and decrement while popping from the stack. subtracting awesome from capasity might provide you the way many factors you have left unfastened. How could you utilize that to get the style of factors used?
masis
2016-10-04 19:20:19 UTC
one way is to maintain a huge determination as area of the class. then you definately increment while pushing, and decrement while popping from the stack. subtracting awesome from capasity might provide you the way many factors you have left unfastened. How could you utilize that to get the style of factors used?
ⓘ
This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.