Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Aprenda while Loop in Java | Getting Started with Loops
Quizzes & Challenges
Quizzes
Challenges
/
Java Loops

bookwhile Loop in Java

Main.java

Main.java

copy
12345678910111213
package com.example; public class Main { public static void main(String[] args) { int number = 1; int sum = 0; while (number <= 5) { sum += number; number++; } System.out.println("Sum of numbers from 1 to 5: " + sum); } }
question mark

Select the correct answer

Tudo estava claro?

Como podemos melhorá-lo?

Obrigado pelo seu feedback!

Seção 1. Capítulo 3

Pergunte à IA

expand

Pergunte à IA

ChatGPT

Pergunte o que quiser ou experimente uma das perguntas sugeridas para iniciar nosso bate-papo

Suggested prompts:

Can you explain what happens if I forget to update the loop variable?

What are some common mistakes to avoid when using while loops?

Can you show how to use a while loop to sum numbers from 1 to 5?

Awesome!

Completion rate improved to 9.09

bookwhile Loop in Java

Deslize para mostrar o menu

Main.java

Main.java

copy
12345678910111213
package com.example; public class Main { public static void main(String[] args) { int number = 1; int sum = 0; while (number <= 5) { sum += number; number++; } System.out.println("Sum of numbers from 1 to 5: " + sum); } }
question mark

Select the correct answer

Tudo estava claro?

Como podemos melhorá-lo?

Obrigado pelo seu feedback!

Seção 1. Capítulo 3
some-alt