Back
You can do something like this:
import java.util.*;public class Main{public static void main(String[] args) {Scanner sc=new Scanner(System.in);int[] arr=new int[5];for(int i=0;i<arr.length;i++){ arr[i]=sc.nextInt();}for(int i=0;i<arr.length;i++){ System.out.println(arr[i]);} }}
import java.util.*;
public class Main
{
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
int[] arr=new int[5];
for(int i=0;i<arr.length;i++){
arr[i]=sc.nextInt();
}
System.out.println(arr[i]);
Want to learn Java? Check out the Java course from Intellipaat.
31k questions
32.8k answers
501 comments
693 users