Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
私は次のコードを持っています...
String t = " "; for(int l=0; l<=5; l++){ t = "Num: " + l + "\n"; } VarPrueba.setText(t);
一連の数値をループしてString、最後にそれらすべてをリストする を生成したいと考えています。出力は次のようになります...
String
1 2 3 4 5
誰かが私のコードを修正する方法を理解するのを手伝ってくれませんか?
次のように変更します。
t+="Num: " + l + "\n";
これを行う最も効果的な方法はStringBuilder、次のようなものを使用することです。
StringBuilder
StringBuilder t = new StringBuilder(); for(int l=0; l<=5; l++){ t.append("Num:"); t.append(l+"\n"); } VarPrueba.setText(t.toString());