We now want to move the Scrambler
interface into the
ScrambledWordLibrary
. The
version of NetBeans that we were using for the recording had a bug. When we
tried to move our interface into the
ScrambledWordLibrary
, it caused a
NullPointerException
. This bug might well have been fixed in a later version
of NetBeans; if not, please let me know in the comments so that we can raise
an issue with the Apache NetBeans project.
If something does not work in one IDE, we don't give up. We simply open the exact same project in IntelliJ IDEA Community Edition and try again.
With IntelliJ IDEA the move into inner class worked well and our
SortedScrambler
, RandomScrambler
, etc. all implement
ScrambledWordLibrary.Scrambler
.
We also create constants inside the
ScrambledWordLibrary
for the
ORIGINAL_SCRAMBLER
, the
RANDOM_SCRAMBLER
, the ROT13_SCRAMBLER
and the
SORTED_SCRAMBLER
. Note that all of these fields are declared as
public static final
, which allows other class to use them (public
), they are defined on the
class (static
) and they cannot be reassigned to something else (final
). The
names of these constants also follow a different convention, with all letters
capitalized and underscores separating the words.
Similarly to NetBeans, we can also set up IntelliJ IDEA to run our Maven test goal before running our application by editing the run configuration and then adding the Maven goal "test" as a precursor to running our game.
We also commit the files with IntelliJ IDEA, just to show how that is done.
We hope you enjoyed this tutorial. If you did, you will also enjoy our courses. We suggest you start with Extreme Java - Advanced Java, followed by Extreme Java - Concurrency Performance for Java 8.
We deliver relevant courses, by top Java developers to produce more resourceful and efficient programmers within their organisations.
We can help make your Java application run faster and trouble-shoot concurrency and performance bugs...