public class {
//these are the arrays I want to store the info in
public static int NumberOfTasks =0;
public static String taskNameArray[];
public static int taskNumberAray[];
public static String taskDescriptionArray[];
public static String developerDetailsArray[];
public static int taskDurationArray[];
public static String taskIDArray[];
public static String StatusArray[];
}
public satic void main(String[] args){
addTask(HowManyTasks);
}
public static void addTasks(int HowManyTasks){
//When I run the file i get an error that says Cannot store to object array because poe_part_2.Task.taskNameArray" is null
for(int i=0 ; i<HowManyTasks ; i++){
taskNameArray[i]= taskName();
developerDetailsArray[i] = developerDetails();
taskDurationArray[i] = taskDuration();
String taskDescription = taskDescriptionArray[i];
while(!(checkTaskDescription(taskDescription = takeTaskDescription())))
{System.out.println("Try again");}
StatusArray[i] = Status();
taskNumberAray[i] = taskNumber();
taskIDArray[i] = createTaskID(NumberOfTasks);
}
}
I tried commenting out some lines but I realised that all the arays have this problem(they are not writing to the arrays that I have set in the public class)
I tried to switch how I assigned the input to the array but complaints from the compiler quickly shut that idea down(so i did this: taskName() = taskNameArray[i];)
New contributor
Simphiwe is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.