| Decimal | Binary |
| 0 | 0 |
| 1 | 1 |
| 2 | 10 |
| 3 | 11 |
| 4 | 100 |
| 5 | 101 |
| 6 | 110 |
| 7 | 111 |
| 8 | 1000 |
| 9 | 1001 |
| 10 | 1010 |
| 11 | 1011 |
| 12 | 1100 |
There are only 10 different kinds of people in the world:
those who know binary and those who don't.
- Anonymous
In Logo, procedure definitions have a header, a body, and a trailer. The header introduces the definition and specifies the name of the procedure. The trailer denotes the end of the procedure definition. All of the lines of instructions in between the header and the trailer are instructions - what the procedure does when it is invoked - the procedure's body. Here is an example of a procedure with a one-line body that prints "Hi!"
to sayHi
println "Hi!
end
In Java, when you write the source code for a class or
a method, you provide two pieces: a header and a body.
Think of the header as an introduction and the body as what
the thing you've introduced consists of. Class and
method bodys have specific
syntax. They start with a left/open squiggly bracket,
are followed by all the stuff (declarations, statements) that
makes them do what you want, and are finished off with a
right/closing squiggly bracket. Here is an example of a
method that does nothing, but has the proper syntax:
void doNothing()
{
return;
}
Now, there is another thing in the Java language that looks
just like the body of a class or method.
In Java-jargon we call this thing a
block statement.
Block statements are allowed to be substituted where Java's
syntax allows any statement to go. The most common places
you will use block statements are in for,
if, and while statements. As an example:
if ( getMouseX() < -50 )
{
if ( getMouseY() > 50 )
return 1;
if ( getMouseY() > -50 )
return 4;
return 7;
}
When you include the word "true" or the word "false" in your source code, it is interpreted as a literal value of type boolean; it's just like putting numbers in your source code which are interpreted as expressions of type int.
The most common use of things (expressions, fields, literals) of type boolean is to provide direction to the Java Virtual Machine - telling it what to do at some point in our program.
However, in 1943, Admiral Hopper was working the development of the Mark II computer which was used for scheduling supply ships, creating ballistic tables for aiming navy guns (the real kind - not for some video game), and other top-secret calculations. As the story goes, at one point when she was getting the system to work she traced a malfunction to a dead moth stuck between two electrical elements. The bug was keeping electricity from flowing between these components of a relay. The moth was taped into the log book with the caption: "First actual case of a bug being found." If you ever have a chance to visit the Naval Surface Weapon Center, check out its museum which is still preserving the "bug."
Back to Table of Contents