このコードを考えてみましょう:
public static void main (String[] args) {
String name = "(My name is Bob)(I like computers)"
StringReader s = new StringReader(name);
try {
// This is the for loop that I don't know
for () {
String result = "";
// Here the char has to be appended to the String result.
}
System.out.println("The string is: " + result);
} catch (Exception e) {
e.toString();
}
}
私が探しているのは、最初に現在の位置にある文字を調べ、次にその文字が「)」でない場合は文字列に追加するforループです。ただし、文字「)」も文字列に追加する必要があります。この例では、出力は次のようになります。
文字列の結果は次のとおりです:(私の名前はボブです)