As an example, in the BFOIT jLogo lessons, you enter source code into the TG applet and/or application.
When we talk in detail about anything, the properties of the thing usually come up. As an example, if we were talking about a balloon, we would probably talk about its color, its size, or whether it is inflated or not. If it is inflated, we might say what it is filled with, e.g., air, water, hydrogen, or helium.
Now, think about representing a balloon in a computer program. Most likely, we would represent the properties as variables in our program. The contents of all of the variables needed for our balloon, at any point in time when the program is executing, is called the state of the balloon.
Imagine a program that models the behavior of a weather balloon. At some point in time during the execution of our program, the variable isInflated would contain true. Another variable, diameter, could contain 1.45, and a third, altitude, could be 32.6. These values represent (make up) the state of the balloon - it is inflated, is 1.45 meters in diameter, and is 32.6 kilometers above earth's surface.
An example of the last feature is:
int variable = 123;
...
System.out.println( "variable contains: " + variable );
In this case, the contents of variable is converted from
an integer into a String and then combined with
"variable contains: " into a single String object which
is passed as an argument to println( ).
The syntax of a programming language is very specific so that its interpreter or compiler can do exactly what the programmer wants. Some languages have a simple syntax, others can be more complex. jLogo is simple (a limited subset of the computer language Logo); it has a fairly simple syntax. On the other hand, Java has a much more complex syntax.
Common syntax errors that you will probably make, regardless of which language you are using are:
Syntax errors unique to Java that are common include:
Syntax errors are caught by the Logo interpreter and the Java compiler; so, a program that has syntax errors will never run. Logo complains when it discovers a syntax error and ignores the command that's bad, and the rest of the commands on the line. The Java compiler also complains when it discovers errors. It will not generate the .class file as long as there are syntax errors.
There are lots of little things you can do to help you keep from making syntax errors, mostly conventions that you adopt and then stick to, every time you write some source code. An example is indenting parts of the source code so that things line up and/or stick out to show the structure of the program.
Back to Table of Contents