Advertisement
Guest User

Scanning java

a guest
Jan 20th, 2019
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.60 KB | None | 0 0
  1.  
  2. package array.input;
  3. import java.util.Scanner;
  4. public class ArrayInput {
  5.  
  6.  
  7. public static void main(String[] args) {
  8. Scanner input = new Scanner (System.in);
  9. System.out.print("How many element do you want to enter/ Array size : ");
  10. int n = input.nextInt();
  11. int a[]= new int[n];
  12. System.out.print("Enter the elemebt : ");
  13. for (int i =0 ; i<a.length ; i++)
  14. {
  15. a[i]=input.nextInt();
  16.  
  17. }
  18. for (int i =0 ; i<a.length ; i++)
  19. {
  20. System.out.print(a[i]+" ");
  21. }
  22. }
  23.  
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement