Try my sample program:
import java.io.*;
class InputArray
{
public static void main (String[] args) throws Exception
{
String[] sample = new String[5];
input(sample);
display(sample);
}
public static void input (String[] args) throws Exception
{
BufferedReader in = new BufferedReader (new InputStreamReader
(System.in));
System.out.println ("Enter 5 values of the String array: ");
int i;
for (i = 0; i < args.length; i++)
{
args[i] = in.readLine();
}
}
public static void display (String[] args)
{
System.out.println ("\nDisplaying the values: ");
int i;
for (i = 0; i < args.length; i++)
{
System.out.println (args[i]);
}
}
}