In this lab you will get acquainted with the workings of arr
Solution
Main.java
import java.util.Scanner;
public class Main {
public static void main(String arg[]){
Scanner input = new Scanner(System.in);
System.out.println(\"how many items do you want to store in an array: \");
int size = input.nextInt();
int[] A = new int[size];
for(int i=0; i<size; i++){
System.out.println(\"Enter item number \"+(i+1)+\": \");
A[i] = input.nextInt();
}
System.out.println(\"The address of your array is \"+A.length);
System.out.println(\"the content of your array is {\");
for(int i=0; i<size; i++){
System.out.print(A[i]+\", \");
}
System.out.println(\"}\");
}
}
Output:
how many items do you want to store in an array:
5
Enter item number 1:
3
Enter item number 2:
4
Enter item number 3:
2
Enter item number 4:
1
Enter item number 5:
5
The address of your array is 5
the content of your array is {
3, 4, 2, 1, 5, }
