0
Please I have an issue with my java array it's not running
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(); System.out.println(sides[i]*sides[i]); }{} //your code goes here } }
5 Answers
+ 2
Code is running fine.
Do you getting any error? What is that?
{} after loop is unnecessary. No use. But it don't make any problem...
+ 3
This looks like it is from a task.
Can you add the task description?
+ 1
Chinaza Augustine
It will better to add error details.
I guess, you are having trouble in executing code here. While you run the code, in the pop-up window add all required inputs by code separated space or by line by line.
For your code : give inputs like
<length> <length number of inputs>
Ex:
2 <press enter>
12 <press enter>
13 <press submit>
Or
2 12 13 <submit>
0
Any help
0
I get errors while running