I need a user to input int and get the name of the month in return. I have this:
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package se211.dz14;
import java.text.DateFormatSymbols;
import java.util.Scanner;
/**
*
* @author Boris
*/
public class Main {
public String getMonth(int month) {
return new DateFormatSymbols().getMonths()[month-1];
}
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here
System.out.println("Please enter month's number:\n");
Scanner scan = new Scanner(System.in);
int month = scan.nextInt();
Main input = null;
String month1 = input.getMonth(month);
System.out.println(month1);
}
}
I'm a beginner, and I'm getting a null pointer exception error. How do I solve this?
Many thanks!