Hi, can someone please help me, I am new to Java and I am getting a NullPointerException error and cant figure out why
Here is the code
class TestBirthday
{
public static void main(String[]args)
{
int num;
System.out.println("Enter number of people to test");
num = Console.readInt();
Birthday2 Experiment = new Birthday2(num);
System.out.println("The number of duplicates when testing " +num+ " people is "+ Experiment.countDuplicates());
}
}
class Birthday2
{
private int num;
private int[]birthday;
public Birthday2(int number)
{
num = number;
int[]birthday = new int[num];
}
public int countDuplicates()
{
boolean duplicate = false;
int index = 0;
int dup = 0;
int day;
while (index < num)
{
day = 1 + (int)(Math.random()*365);
{
duplicate = searchBirthdays(day,index);
if (duplicate)
dup ++;
}
birthday[index] = day;
index ++;
}//end while
return dup;
}//end selectBirthday