Java program for 1D Array
import java.util.Scanner;
public class OneDimArray
{
public static void main(String args[])
{
int a[]=new int[10], i;
Scanner s=new Scanner(System.in);
System.out.println("Enter 10 numbers");
for(i=0; i<10; i++)
{
a[i]=s.nextInt();
}
System.out.println("List of numbers");
for(i=0; i<10; i++)
{
System.out.print(a[i]+" ");
}
System.out.println("\n");
}
}
Output
Enter 10 numbers
1 2 3 4 5 6 7 8 9 10
List of numbers
1 2 3 4 5 6 7 8 9 10
Comments