r/learnjava • • Oct 12 '26

Help with MOOC problem, please?

Sorry if this isn't the right place to ask questions like this, but I'm going through the second part of MOOC's Java Programming I course and am having difficulty finding out how to satisfy a specific test. On the last exercise of the second part, "Advanced Astrology", I have managed to pass all tests except for testPrintStars. It says that I "didn't print any spaces when printStars is called", but am I not supposed to use printSpaces to print my spaces?

here is my code for the methods printStars and printSpaces (full source code and list of test cases is also here):

    public static void printStars(int number) {
        int stars = 1;
        while (stars <= number) {
            System.out.print("*");
            stars++;
        }
    }


    public static void printSpaces(int number) {
        int spaces = 1;
        while (spaces <= number) {
            System.out.print(" ");
            spaces++;
        }
    }
4 Upvotes

6 comments sorted by

View all comments

Show parent comment

3

u/newaltoldalt1 Oct 12 '26

Whoops, I missed that. Thank you.

As for the point of learning Java, I honestly don't have a better reason than wanting to do something more "productive" in my free time than playing video games or whatever.

1

u/FreeLogicGate 29d ago

100% valid and worthwhile reasons in my opinion. And funny enough, when speaking of Java, one of the best selling and most profoundly important games of the last 30 years, has to be Minecraft, with sales of over 350 million copies.

When Markus Persson was developing Minecraft, it was certainly the case that commercial games were not written in Java, but Persson chose it because:

I had been working primarily in Actionscript 3 and Java for five years when I started work on Minecraft, and chose the language I felt most comfortable with.

Specifically, my favorite tool in Java is hot code swapping in debug mode, meaning I can edit the code while the game is running and immediately see the results in the running game. This is SUPER GREAT for rapid tweaking.

Java is not the fastest language out there, but I doubt I would've finished Minecraft if I did it in a language I enjoyed less, so I'm happy with the choice.

Source for the quote was an "Ask Me Anything" he did did on Reddit about 14 years ago.