Learning Java: Day 2

Classes and Objects
Here we are in Chapter 2 of "Head First Java"

I'm having hold-over problems from yesterday. My VERY simple programs compile, but I don't know where the output is going. Translation: The code that I'm writing appears to work correctly but it's supposed to write out simple sentences and I don't know where those sentences are going.  

I've sent out an email distress call  to my programmer daughter-in-law for help. She will undoubtedly find this very funny but will be able to explain in simple words how to view my program output.

Today I learned the difference between a class and an object. A class is like a teddy bear machine and the object is the ballerina teddy bear or the soldier teddy bear (or whatever else kind of bear) that is made by the teddy bear machine.

Each class has things that it "knows" and things that it "does".  So in the example of the teddy bear machine, it would "know" the bearModel, the bearSize, and the bearClothing. The things it "does" might be getSize() (you push the size button), setSize(), getModel() (you push the model button), setModel(), getClothing() (you select the clothing buttons), setClothing(), and assembleBear(). The object, in this example, is the teddy bear that drops out of the machine.

So, a class is like a blueprint, an object is (or objects are) what's made from the blueprint. Or, as the book says, "a class is like a recipe; objects are like cookies."

The rest of the chapter consists of practice, exercises, and a puzzle.

I'm glad this chapter is short.  After a day of housecleaning, laundry, ironing, and baking cookies, there wasn't a whole lot of time to spend on the computer.

I'm pooped.  It's bed time.  Nighty night!

2 comments:

Anonymous said...

Hi Suki,
Your disappearing sentences remind me of my disappearing pdf documents. Daisy

Edda Mome said...

Well, sad to say but it is just user error on my part. I explain what the problem was and the solution in Day 4.

It's good to know people that are way smarter than I am. :-P

Post a Comment