我想存儲所有可能的子串在String []
。我試過這個,但得到一個錯誤:存放在字符串中所有可能的子[]
public void sub(String word){
String [] Str=new String[100];
int n=0;
for (int from = 0; from < word.length(); from++) {
for (int to = from + 1; to <= word.length(); to++) {
str[n]=word.substring(from, to);
n++;
System.out.println(str[n]);
}
}
}
什麼是解決方案?
有什麼錯誤? – PakkuDon
當你輸入你的問題時,它旁邊有一個橙色的方框,標題爲「如何格式化**」。值得一讀。頂部還有一個工具欄,用於製作格式,標記代碼等等,方便,並在下方顯示預覽區域,以準確顯示您的問題在發佈時的樣子。對於你的下一個問題,請使用這些工具。 (另外,縮進你的代碼。)這次我爲你糾正了一些事情。 –
好吧,我明白了。錯誤是:無法找到符號,變量str,loction:class substring – user3359479