Java Reference
In-Depth Information
interface The interface of a class describes what a class does and how it can be used with-
out showing the implementation.
implementation The complete source code that defines a class is called the implementation
of that class.
immutable An object is said to be immutable if its contents or state cannot be changed once
it has been created. Strings are an example of immutable objects.
map A map is a collection that stores key/value pairs as entries. Values can be looked up by
providing the key.
set A set is a collection that stores each individual element at most once. It does not maintain
any specific order.
documentation The documentation of a class should be detailed enough for other program-
mers to use the class without the need to read the implementation.
access modifier Access modifiers define the visibility of a field, constructor, or method.
Public elements are accessible from inside the same class and from other classes; private ele-
ments are accessible only from within the same class.
information hiding Information hiding is a principle that states that internal details of a class's
implementation should be hidden from other classes. It ensures better modularization of an
class variable, static variable Classes can have fields. These are known as class variables
or static variables. Exactly one copy exists of a class variable at all times, independent of the
number of created instances.
Exercise 5.71 There is a rumor circulating on the Internet that George Lucas (the creator of
the Star Wars movies) uses a formula to create the names for the characters in his stories (Jar
Jar Binks, ObiWan Kenobi, etc.). The formula—allegedly—is this:
Your Star Wars first name:
1 Take the first three letters of your last name.
2 Add to that the first two letters of your first name.
Your Star Wars last name:
1 Take the first two letters of your mother's maiden name.
2 Add to this the first three letters of the name of the town or city where you were born.
And now your task: Create a new BlueJ project named star-wars . In it create a class named
NameGenerator . This class should have a method named generateStarWarsName that
generates a Star Wars name, following the method described above. You will need to find out
about a method of the String class that generates a substring.
Search WWH ::

Custom Search