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

1.8 StaticWordLibrary Details

Juppies 2 by Dr Heinz M. Kabutz

We now look at the nitty-gritty details of the StaticWordLibrary.

We begin with the WORD_LIST, which is private (hidden inside our class), static (one field being shared by all objects of type StaticWordLibrary) and final (cannot be reassigned to another value). Because the field is static and final, we consider it as a constant, which means we use a different naming convention for the name. For normal classes and fields we use CamelCase - with the intermediate words capitalized. This works great in English, but not so great in German where nouns are combined into a single word (e.g. Donaudampfschifffahrtselektrizitätenhauptbetriebswerkbauunterbeamtengesellschaft). Perhaps this is why lots of German companies standardize on English for variable names? An example of CamelCase is the StaticWordLibrary.

The WORD_LIST is what we call an array of Strings, represented by the square brackets [] after the String.

In our StaticWordLibrary the characters of the words are always shuffled in the same way. "abstraction" is always "batsartcoin" and once we've figured that out, the game becomes a bit too easy to be fun.

The index of arrays in Java always starts at 0 and goes up until length - 1. When we start programming, this might seem like a strange convention, but the arithmetic for working with indexes becomes a lot simpler than if we were to start at 1.

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.