Code: Select all
Exception in thread "main" java.lang.NullPointerException: Cannot invoke "java.util.ArrayList.add(Object)" because "this.account_holder_names" is null
at Achul/admindashboard.sales.add_account_details(accounting.java:14)
at Achul/admindashboard.accounting.main(accounting.java:56)
Code: Select all
package admindashboard;
import java.util.ArrayList;
class sales{
ArrayList account_holder_names;
ArrayList sale_value;
ArrayList bank_account_numbers;
ArrayList regional_bank_codes;
ArrayList courses_sold;
boolean add_account_details (String account_holder_name, long sale_amount, String bank_account_number_1, String bank_regional_code, String course_sold)
{
account_holder_names.add(account_holder_name);
sale_value.add(sale_amount);
bank_account_numbers.add(bank_account_number_1);
regional_bank_codes.add(bank_regional_code);
courses_sold.add(course_sold);
return true;
}
Ich habe die Datei gespeichert, bevor ich sie ausgeführt habe.
Ich habe versucht zu überprüfen, ob die Anweisung solche Deklarationen erfordert. Das ist nicht der Fall.
Ich habe erwartet, dass es läuft, da es keine Fehler gab.
Mobile version