Friday, 29 March 2013

Java Program To Input and Print Array

Java program to input and print array

import java.io.*;

class ArrayDemoIo {


public static void main(String[] args)
{
InputStreamReader isr = new InputStreamReader(System.in);
BufferedReader br = new BufferedReader(isr);

int a[] = new int [5];
int i;

for(i =0 ;i<= 4 ; i++)
{
try
{
a[i] = Integer.parseInt(br.readLine());
}
catch(Exception e)
{
System.out.println("Exception in io or coversion");
}
}
for(i =0 ;i<= 4 ; i++)
{
System.out.println("a["+i+"]= "+a[i]);
}


}

}

0 comments:

Post a Comment

 

Copyright @ 2013 Appychip.

Designed by Appychip & YouTube Channel