This week's book giveaway is in the Mac OS forum. We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell on-line! See this thread for details.
Note that if I wanted to define an object type (or class) of Foo, I'd write something like the following.If I wanted to define an abstract object type, I'd write something like the following.Here is a list of free on-line Java tutorials and books that I have found useful:
I made Fruit an abstract class. That means that you can use it to base other classes on, but you can't make Fruit objects directly.
The Apple class has everything that the Fruit class has because it extends the Fruit class. Fruit is the "superclass" and Apple is the "subclass". But now the Apple class has something that the Fruit class does not: a String called myMoto.
So now you can create (in other words, "instantiate") an Apple object and print out its values. I'll call my Apple object "a".
Notice how the "a" object has a hasVitaminC variable. That's because the "a" object is an instance of the Apple class. The Apple class extends the Fruit class, and the Fruit class has a hasVitaminC variable.
Moto = One of me a day keeps the Doctor away Has Vitamin C = true
My Orange class has everything that the Fruit class has, plus a juicynessFactor variable.
My Cherry class has everything that the Fruit class has, plus a warning variable.
Just a note on naming classes: I called the class Apple instead of Apples because class names are singular by convention. I called the class Apple instead of apple because class names start with an uppercase letter by convention.