Statements are the work horse construct of any text based programming language. Statements are where action happens and where you encode your algorithm into instructions for your robot. Statements fall into two categories, actions with assignment of a resulting value to a variable and actions that do not assign a result:


A Variable is a memory location, or 'slot', reserved by your program into which you will store data. It is called a variable because we can change it as needed as the program executes. When we define variables we assign them meaningful names instead of having to work with actual memory addresses. Here are some examples:

Basic Syntax

As we move forward, we will start to acquire new vocabulary at an increasing rate. It is normal for vocabulary to take a while to stick, so don’t give up! Additionally, syntax is something you will learn by doing (and messing up!). Syntax is a challenge that you will always be getting better at, and is something nobody is perfect at.

Hello World!

The most common example of a first Java program is the famous Hello World! program. Before we get into the details of Hello World, I am going to introduce some of the supplemental resources we will be using.

What Level (scope) are we working at?

Software systems are typically made up of several layers of programs, each providing services to the layer above. Robots are no different. In a robot, there will be a layer below your program that provides services to the programs you will write. This layer below (an API) hides complexity or details that have already been programmed for you and you can ignore. There may also be a layer above your program that tells your program when to stop and start and may provide input. In that sense your program is providing a service to that higher layer.

What is a Program?

Simply put, a program is a set of instructions that describe the actions we want a computer to take to reach the desired output (result) from a set of input(s). That set of actions, taken as a whole, is also called an algorithm. The instructions to making a peanut butter and jelly sandwich qualify as an algorithm:

How do we use Java?

So how do we produce Java programs? Java is a text  based language, so the first step is to write the source code for our Java application using a text editor and save that source text in a file. You can use any editor you wish.

Next that source file is passed to the Java compiler. The compiler reads the Java source and checks for errors and if no errors are found, outputs the appropriate bytecode to a second file for execution.

Applications vs Apps vs Applets vs Servlets

An aspect of the Java "write once, run anywhere" design, is that Java programs can be run in one of several execution "models" or "contexts". Java programs can be run as "Applications", "Apps", "Applets" or "Servlets".

Java Language Architecture

Java is a text based programming language. This means source code is written and stored in a text file and then passed through a compiler which produces the executable program (also called the object code). With C or C++ and other languages, the language and resultant executable program is tailored to a specific operating system or hardware platform. For example, a Windows program written in C will only execute on a Windows device and may or may not run on all variations of Windows or Windows devices.

What is Java?

Java is a general purpose programming language developed in the mid 1990s by Sun Microsystems. Java is now owned by Oracle Corp. Java is a text based, object oriented, class based programming language (we will learn what these terms mean later). In addition to the language itself, Java is designed to allow a program to be written once on a selected hardware and operating system platform and then executed on different hardware and operating system platforms through the use of virtual machine technology.