我想爲應用程序創建一個「無限」字符串列表。我試圖用這個....創建無限字符串
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