Mar 20, 2010

Java Program for intializing and printing a Two-dimensional array

public class Twoarray
{
    public static void main(String args[])
    {
        int a[][]={{5,2},{1,4},{2,3}};
    System.out.println("given Two-dimensional array is: ");
        for(int i=0;i<3;i++)
        {
            for(int j=0;j<2;j++)
            {
                System.out.print(a[i][j]);
            }
        System.out.print(" ");
        }
    }
}

Java Program for printing the Fibonacci Series

class Fibonacci
{
 public static void main(String[] args)
 {
 int a=0,b=1,s=0;      
 System.out.println("Fibonacci series printing 10times:"); System.out.println(a);
 System.out.println(b);
 int i=0;
 while(i<10)
     {
            s=a+b;
            a=b;
            b=s;
            System.out.println(s);
            i++;
            }
    }
}