Skip to content

Instantly share code, notes, and snippets.

@manjaykumardp
Created February 19, 2022 16:01
Show Gist options
  • Save manjaykumardp/d521260adf08580df43a0c3e4816034b to your computer and use it in GitHub Desktop.
Save manjaykumardp/d521260adf08580df43a0c3e4816034b to your computer and use it in GitHub Desktop.
Input array and print it in Java
package com.manjay;
import java.util.Scanner;
public class inputarray {
public static void main(String[] args) {
System.out.println("Enter numbers of element");
Scanner sc = new Scanner(System.in);
int num = sc.nextInt();
int[] arr = new int[num];
for (int i = 0; i <arr.length ; i++) {
arr[i]=sc.nextInt();
System.out.print(arr[i]+" ");
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment