Thursday, May 12, 2016

Example of array

Simple example of array is shown below:


package monthactual;

import java.util.Scanner;

public class MonthActual {
    int n;
    String[] month= { "january","february","march","april","may","june","july","august","september","october","november","december"};
    Scanner sc=new Scanner();
    public void actualMonth(){
        for (int i=0;i<month.length; i++){
            System.out.println("Enter the no of month:");
            this.n=sc.nextInt();
            System.out.println("the actual month is" +month[n]);

        }
    }
}

No comments:

Post a Comment