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.
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...