Java… I Choose You!

About a month ago, right before Tales of Arise came out, I picked up a number of courses from Udemy. The itch to learn something was upon me and would not be denied! Delayed a little bit, but not denied. Honestly, I’m somewhat impressed with myself. Normally letting an interest like that pass by for a month without doing anything about it all but ensures the flame snuffs out.

But here we are! I did initially have a bit of a pause in deciding exactly what to start out on. I did give myself… a few options, after all. :)

My last Udemy haul.

As the title no doubt gives away, I went back to my roots and opted to start with the Java course.

It somewhat blows my mind that we’re up to Java 17 now — when I last did any hands-on code for University, Java 6 was the latest and greatest but we were taught on 5.

I’d really like to not dwell on just how long ago that was too much. ;)

What I’ve found to be most incredible though is just how vividly memories thought lost to the mists of time are resurfacing. Not just the concepts themselves, but being in the lecture hall — the lecturer’s slides, the notes I took, the experience in general.

I remember a lot of the coursework and projects, too. I really wish I had been better about back-ups in those days. But I wasn’t, so that old code is even more lost than I thought the memories and associated knowledge were.

These are being unlocked by the most random of things though, so I’ve resisted jumping ahead. Noting the differences in course structure, and the order content has been tackled is interesting too. University by now had covered a lot of depth in functions available on some of the common built-in classes (e.g., String and the primitive wrapper classes like Integer).

By comparison, this course has (for the most part) steered clear of those until now, opting to instead teach more of the raw coding logic to get a thing done. Although perhaps to say that isn’t quite right either — the course teaches the core concepts, but it is left up to the individual to really parse these concepts and apply the logic called for by the challenges.

So far, the code asked for in challenges has been very basic. e.g.:

    public static boolean hasSharedDigit(int num1, int num2) {
        // Accepts 2x 2-digit integers and returns true if they share a common digit.
        // Returns false if no common digits are found or invalid input is provided.
        if (num1 < 10 || num1 > 99 || num2 < 10 || num2 > 99) return false;
        int num1Digit = 0;
        int num2Digit = 0;
        int num2Placeholder = num2;
        while (num1 != 0) {
            num1Digit = num1 % 10;
            while (num2 != 0) {
                num2Digit = num2 % 10;
                if (num1Digit == num2Digit) return true;
                num2 /= 10;
            num2 = num2Placeholder;
            num1 /= 10;
        return false;

I think the constraint of having inputs with a maximum of two digits was to allow for solutions that didn’t involve nested loops. Scanning through the Q&A board, I certainly found a lot of people who posted solutions that isolated the four digits and then ran the comparisons.

On the other hand, I’ve also seen some truly elegant solutions to some of the problems that made my own look downright hamfisted in comparison!

The example code I posted above though I quite enjoyed — it was a good reminder of how integer division works and the interplay with the % operator (modulus/remainder). e.g., dividing 199 by 100 will return an answer of 1. The other 99 discarded, no rounding here!

This behaviour can be useful though, in isolating individual digits and then removing them. Taking 199 again as the example — division by 10 would give you 19, or the left-most digits. The modulus operation of 199 % 10 gives you the remainder, or in other words, isolates the one’s place value, 9 in this case.

By University teaching, at this early stage of learning, I would have perhaps approached this problem by converting each digit to a string via the toString() method and stepped through each character in the string performing the comparison instead.

So if nothing else it’s good to be reminded of the fact there are a myriad of valid ways to approach such problems.

As for my progress, I’m a few lectures and challenges away from completing what I suppose you could consider as being the basic coding fundamentals. Still to basics of Object Orientated Programming to get a refresher on, then into the fun that is Generics, Inheritance, Unit Tests and all that good stuff.


Gamer, reader, writer, husband and father of two boys. Former WoW and Gaming blogger, making a return to the fold to share my love of all things looty.

Newest Most Voted
Inline Feedbacks
View all comments
%d bloggers like this: