I have a java class which generates Strings. Now I thought I don't want to return an array of string but only one string per call with a "getNextString" method. Then one can call the method in a loop like that:
while(abc.getNextString() != null) {
...
}
I have seen this a few times in java I guess but now I wonder if there is a pattern or a best practice for methods like that? The method depends on start values so where should I initialise them? What happend if the initialise method is called by another peace of code before all strings are returned?
Whould be nice to see something about that! :)