我想为应用程序创建一个“无限”字符串列表。我试图用这个....创建无限字符串
public static void runinfinite(int length) {
String lastString= " ";
while (true) {
if (lastString.length() > length)
break;
lastString = lastString.trim();
for (char c0 = 'a'; c0 <= 'z'; c0++) {
lastString += c0;
action(lastString);
}
}
}
它只是给了我这样的:abcdefghijklmnopqrstuvwxyz
。有没有人有一段代码会使字符串'无限'?
编辑:我需要做一个字符串列表像this example:并不需要在相同的顺序,只是一堆字符串]
编辑2:我想使this example工作得更好,并永远运行。
无限将导致stackoverflowexception – tehdoommarine
我不太清楚你想要做什么。什么是无限的字符串列表?你能做出一些永不停歇的事情吗? –
听起来像你想[流](http://en.wikipedia.org/wiki/Stream_(type_theory))。 – oldrinb