私はこの質問がすでに何度か尋ねられていることを知っています。それを重複としてマークしてください。とにかく、私はまだ不確かなので、むしろコミュニティに尋ねたいと思う。Javaのdo-whileループでwhileループを変換する
私はdo-whileループでwhileループを変換する必要があります。 考えていますか?ループを使用すると、条件に関係なく起こります反復を持っている間ループは、それらの間の主な違いはないしている間に
public class DoWhile {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
int sum = 0;
System.out.println("Enter an integer " + "(the input ends if it is 0)");
int number = input.nextInt();
while (number != 0) {
sum += number;
System.out.println("Enter an integer " + "(the input ends if it is 0)");
number = input.nextInt();
}
}
}
にあなたの質問にすべての読者を助けたいですインデントと正しい改行。編集を検討してください。 – Matt
質問のようなコードレビューのようです。 http://codereview.stackexchange.com/ –