Wednesday, August 17, 2011

One dimensional Array in java



import java.io.*;

class array
{
 public static void main(String[] arg)
  {
   int n;
   BufferedReader in=new BufferedReader(new InputStreamReader(System.in));
   int arr[]=new int[30];
    try
    {
System.out.print("Enter the number of elements of array: ");
      n=Integer.parseInt(in.readLine());
     for(int i=0;i<n;i++)
      {
System.out.print("Enter the value of"+(i+1)+" th elements of array: ");      
        arr[i]=Integer.parseInt(in.readLine());
      }
      System.out.println("Elements of array:");
      for(int i=0;i<n;i++)
      {
       System.out.println(arr[i]);
      }
     }
    catch(Exception e){ }
   }
}

Previous Next Home
0 Comments
Comments

Leave a Comment

:)) ;)) ;;) :D ;) :p :(( :) :( :X =(( :-o :-/ :-* :| 8-} :)] ~x( :-t b-( :-L x( =))

Twitter Delicious Facebook Favorites More