Running on Java 17+35-2724 (Preview)
Home of The JavaSpecialists' Newsletter

3.12 Moving Scrambler Interface Into ScrambledWordLibary Using IntelliJ IDEA

Juppies 2 by Dr Heinz M. Kabutz

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.

Comments

When you load these comments, you'll be connected to Disqus. Privacy Statement.

Table of Contents

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.



About the Author

Heinz Kabutz Java Conference Speaker

Java Champion, author of the Javaspecialists Newsletter, conference speaking regular... About Heinz

Superpack 21

Superpack 21 Our entire Java Specialists Training in one huge bundle more...

Free Java Course

Free Juppies 2 Course
Juppies 2 - a course for complete beginners more...

Free Java Book

Dynamic Proxies in Java Book
Java Training

We deliver relevant courses, by top Java developers to produce more resourceful and efficient programmers within their organisations.

Java Consulting

We can help make your Java application run faster and trouble-shoot concurrency and performance bugs...

Java Emergency?

If your system is down, we will review it for 15 minutes and give you our findings for just 1 € without any obligation.