[Code@Cafe] JAVA-Input Array dari Panjang Array yang Diinginkan

import java.util.Scanner;

class customizeArray
{
static Scanner input = new Scanner(System.in);

public static void main (String[] args)
{
int i;
System.out.println(“Inputkan panjang array : “);
int n = input.nextInt();
int[] array = new int[n];

System.out.println(“Inputkan nilai array : “);
for(i=0;i<n;i++)
{
int j = input.nextInt();
array[i] = j;
}

System.out.println(“Panjang array : “+n);
System.out.println(“Tampilkan nilai array : “);
for(i=0;i<n;i++)
{
System.out.println(array[i]);
}
}
}

 

Advertisements

WordPress.com.

Up ↑