Skip to content
EricDeiman edited this page Oct 21, 2015 · 14 revisions

What's all that stuff in the FirstThingsFirst directory?

When you look in the FirstThingsFirst folder, you'll see several files with funny names and a strange looking folder. Something like this:

src
.classpath
.gitignore
.project

The src folder is where the source code will go. If you click on the name, you'll see one java file.

The other files are things that you can ignore, if you want to. You can look at them if you'd like, but don't change any of the contents.

The .classpath file is created by Eclipse and contains information that helps Eclipse find different libraries of code other people have written.

The .gitignore file is used by git to know which file NOT to put up on GitHub.

The .project file is used by Eclipse to store information about our specific project.

What's all the gobbledygook in the HelloWorld.java file?

The file starts off with a strange looking /* that marks the beginning of a comment. In programming, a comment is ignored by the language and is intended to help a human reader understand why the code does what it does. The symbols */ mark the end of the comment. So, the comment that starts on line 1 ends on line 18.

Like most other open source files, this file starts off with a copyright notice. This particular license allows anyone to use the code as long as they make any changes to the code open source.

The next comment is a short description of why the program was written.

Then we have public class HelloWorld { that's all colorful. The color is GitHub's way of marking code that the programming language will pay attention to.

Java is an object-oriented language. This means that (almost) everything is Java is an object. In source code, we use the word class to describe what objects can do. (For now, skip over the word public; we'll cover that later.) The phrase HelloWorld is the name of our fist class. Note that this is also the name of the source code file. In Java, every source code file must contain a class with the same name as the file.

The { is the way Java has to group lines of source code into a block. Each { has a matching } symbol. All the code for our class is in the block that starts on line 27 and ends on line 39.

Then there's another comment that goes from line 29 to line 35. You can read that at your leisure.

Next, the code says public static void main( String[] args ) {. This phrase marks the beginning of a method. There's that word public again. And, again, we're going to skip it and cover it in a later lesson. We're also going to skip static. And void. The word main has special meaning to Java. It marks the part of the code that executes when the program starts running. It labels what we call the entry point of the software. Not every class you write will have a main method. We'll cover what's in the parenthesis in another lesson. Finally, there's another { (called the "opening curly bracket" or "opening curly brace"). This marks another block of code; the code that will run when the method main is called.

The next line is System.out.println( "Hello world!" );. In short, when we want to write a message to the console, we start with System.out.println. Then we put the message we want to write inside the parenthesis and in quotation marks. How would you change that line so the system prints Hello Eric? The semicolon ; is used to mark the end of one instruction for the language. In a more complicated program, there would be more instructions followed by more semicolons. But, in this simple example we only need one instruction.

Clone this wiki locally