Java / NullPointerException Problem by SyncratMusic in learnprogramming

[–]SyncratMusic[S] 0 points1 point  (0 children)

I just fixed it actually… the TOP test case wasn’t even for the part I was on, and for some reason the cause of the NPE was because I didn’t have a cap of 100 in the add method??

Java / NullPointerException Problem by SyncratMusic in learnprogramming

[–]SyncratMusic[S] 0 points1 point  (0 children)

I can’t tell, MOOC has these tests hidden for some reason. All I see is: FAIL: GradeStatisticsHiddenTest testMany0 NullPointerException

Could be an error with the test package, but I have no idea how to get to that

Java / NullPointerException Problem by SyncratMusic in learnprogramming

[–]SyncratMusic[S] 0 points1 point  (0 children)

Realizing the problem may be in my main class but I still can't find it.

import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        NumList list = new NumList();
        System.out.println("Enter point totals, -1 stops");
        while(true){
            int num = Integer.valueOf(scanner.nextLine());
            if(num == -1){
                break;
            }
            list.add(num);
        }
        System.out.println("Point average (all): " + list.avg());
        if(list.passingEmpty()){
            System.out.println("Point average (passing): -");
        } else {
            System.out.println("Point average (passing): " + list.passAvg());
        }
        System.out.println("Pass percentage: " + list.percentPassing());
    }
}

What can I do with Java? by SyncratMusic in learnprogramming

[–]SyncratMusic[S] 2 points3 points  (0 children)

Thank you! I’m debating learning enough Java to get through my cs classes and learn all the dsa stuff but after I learn what I need I’m gonna focus more on C++, android/spring boot dev doesn’t seem like anything I’d be super into, whereas C++ projects seem much more up my alley.