Please explain to me, I don't understand. what means is a first "for" | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Please explain to me, I don't understand. what means is a first "for"

import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int length = scanner.nextInt(); int[] sides = new int[length]; for (int i = 0; i < length; i++) { sides[i] = scanner.nextInt(); } for(int t : sides){ System.out.println(t*t); } } }

22nd Oct 2021, 8:18 PM
Nikita Skoruk
Nikita Skoruk - avatar
2 Answers
+ 2
In the first for-loop we get user input. The user input is filled in the sides array
22nd Oct 2021, 8:33 PM
Lisa
Lisa - avatar
- 1
in your code first 'for()' is for (int i = 0; i < length; i++) {
22nd Oct 2021, 10:24 PM
zemiak