Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Aprenda Usando Loops Com Arrays | Arrays
Noções Básicas de Java

Deslize para mostrar o menu

book
Usando Loops Com Arrays

How to Iterate Through an Array Using Loops?

Arrays and loops are frequently used in tandem. When dealing with a large array containing 100 or even 1000 elements, manually working with and extracting each element would be impractical. Just imagine how time-consuming it would be to manually fill such an array...

Como Iterar Por um Array Usando Loops?

Arrays e loops são frequentemente usados em conjunto. Ao lidar com um grande array contendo 100 ou até 1000 elementos, trabalhar e extrair manualmente cada elemento seria impraticável. Basta imaginar quanto tempo seria necessário para preencher manualmente um array tão grande...

java

Main

copy
123456789101112
package com.example; public class Main { public static void main(String[] args) { //initializing our char type array char[] charArray = {'c', 'o', 'd', 'e', 'f', 'i', 'n', 'i', 't', 'y'}; //printing our array using for-loop for (int i = 0; i < charArray.length; i++) { System.out.print(charArray[i]); } } }

Let's take a closer look at how the loop iterates over an array:

java

Main

copy
12345678910111213
package com.example; public class Main { public static void main(String[] args) { //initializing our char type array char[] charArray = {'c', 'o', 'd', 'e', 'f', 'i', 'n', 'i', 't', 'y'}; //printing our array using for-loop for (int i = 0; i < charArray.length; i++) { System.out.println("Now variable i = " + i + ", and value of charArray[" + i + "] = " + charArray[i] + ";"); /*the value of "i" is incrementing with every loop iteration*/ } } }
Tarefa

Swipe to start coding

Let's practice working with loops and arrays on your own. Your task is to populate an array with numbers from 1 to 10 using a for loop and then display it on the console. Remember that the numbers should be arranged in ascending order.

Solução

java

solution

Switch to desktopMude para o desktop para praticar no mundo realContinue de onde você está usando uma das opções abaixo
Tudo estava claro?

Como podemos melhorá-lo?

Obrigado pelo seu feedback!

Seção 4. Capítulo 2
Sentimos muito que algo saiu errado. O que aconteceu?

Pergunte à IA

expand
ChatGPT

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

book
Usando Loops Com Arrays

How to Iterate Through an Array Using Loops?

Arrays and loops are frequently used in tandem. When dealing with a large array containing 100 or even 1000 elements, manually working with and extracting each element would be impractical. Just imagine how time-consuming it would be to manually fill such an array...

Como Iterar Por um Array Usando Loops?

Arrays e loops são frequentemente usados em conjunto. Ao lidar com um grande array contendo 100 ou até 1000 elementos, trabalhar e extrair manualmente cada elemento seria impraticável. Basta imaginar quanto tempo seria necessário para preencher manualmente um array tão grande...

java

Main

copy
123456789101112
package com.example; public class Main { public static void main(String[] args) { //initializing our char type array char[] charArray = {'c', 'o', 'd', 'e', 'f', 'i', 'n', 'i', 't', 'y'}; //printing our array using for-loop for (int i = 0; i < charArray.length; i++) { System.out.print(charArray[i]); } } }

Let's take a closer look at how the loop iterates over an array:

java

Main

copy
12345678910111213
package com.example; public class Main { public static void main(String[] args) { //initializing our char type array char[] charArray = {'c', 'o', 'd', 'e', 'f', 'i', 'n', 'i', 't', 'y'}; //printing our array using for-loop for (int i = 0; i < charArray.length; i++) { System.out.println("Now variable i = " + i + ", and value of charArray[" + i + "] = " + charArray[i] + ";"); /*the value of "i" is incrementing with every loop iteration*/ } } }
Tarefa

Swipe to start coding

Let's practice working with loops and arrays on your own. Your task is to populate an array with numbers from 1 to 10 using a for loop and then display it on the console. Remember that the numbers should be arranged in ascending order.

Solução

java

solution

Switch to desktopMude para o desktop para praticar no mundo realContinue de onde você está usando uma das opções abaixo
Tudo estava claro?

Como podemos melhorá-lo?

Obrigado pelo seu feedback!

Seção 4. Capítulo 2
Switch to desktopMude para o desktop para praticar no mundo realContinue de onde você está usando uma das opções abaixo
Sentimos muito que algo saiu errado. O que aconteceu?
some-alt