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

1.2 WordLibrary

Juppies 2 by Dr Heinz M. Kabutz

We start with the model that we will use for this course - the WordLibrary. The class is stored in the directory eu/javaspecialists/courses/juppies2/anagrams/lib and thus it gets the package name that mirrors that path: eu.javaspecialists.courses.juppies2.anagrams.lib. Why this? Well, I own the domain name javaspecialists.eu, so we reverse that and get the prefix. Next I have a subpackage called courses and then inside there our juppies2 course. In case you are wondering, yes, there was also a juppies course, which was based mainly on using jshell to learn Java. I wrote that a few years ago when I spent a lot of time in airport lounges. My idea was to record a whole course whilst waiting for my flights. Check that other course out here.

The class WordLibrary is public which means everybody can see it. It is abstract, which means that we cannot make an object of this class, but we can create implementations of this. That all sounds complex now, but it will become clear soon.

Our IDE uses syntax highlighting to show us what is important. Comments are useful to understand how the code works, but they don't actually do anything. They are thus in a grey colour.

Java is a strongly typed language, good for people with weak memories. If we make a mistake, the compiler will alert us. With weakly typed languages, our code blows up when we run it.

Java follows C's convention of separating statements with the semicolon ; - this is a great key to use if you use a US keyboard, but gruesome when coding on a European layout. The semicolon fits on the right pinky finger. If all fails, learn how to touch type and then code with the US layout. Or give up and use Kotlin or Scala :-)

We mention that to compare objects, we need to use the equals() method. Comparing them with == will not give us the correct result. We will discuss this in more detail in a later lecture.

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.