Hello there! Today I am going to give you a little crash course into the very interesting world of Java coding. You should follow this tutorial BEFORE following any of my later tutorials!

Step 1: So You Want to Code?

So you want to code huh? Well coding is more advanced than it seems. You are NOT coding if you copy/ paste code from websites that post whole source code files. This is what is know in the coding community as "spoon-fed" code. You do not learn from this and you are basically copying someone else's work. So my coding tutorials will show you the BASICS of Java, and I will not be posting the source files of my applications. Once you learn the basics of Java, we can get into more advance things.

Step 2: Thinking Like a Coder

Before we even get into coding, you need to think like a code. Java is an object-oriented coding language, meaning it is based around the idea of objects.
[More Info]

You must also get your head around the idea of variables. A variable is just like a variable in Algebra. It stores information that you can use or manipulate at a later time. Variables in coding are different from variables in math in the sense that variables in code can store pretty much any kind of information. 
[More Info]

Step 3: Speaking Like a Coder

If you've ever head a coder talk, you may have been wondering "WTF are they saying???". I will teach you how to decode the code (pun intended) lingo.

A string refers to a string of text. That's it.

Integer/ int
An Integer (which I will refer as int from now on) is any number between 0 to 2^32-1. (Integers and ints are different, but I'll teach you about the difference in a later time).

A boolean (pronounced boo-lee-ann) is a value that is true/ false, yes/ no, on/ off, or 1/ 0. Basically it is true or false. There are no other values that a boolean can have (Yes there is, but I'll show you later).

For the sake of a short tutorial, I'll keep it to those 3. There are PLENTY of other coding terms, that I won't go into detail over, such as floats, doubles, longs, shorts, chars, and bytes. You can read more about all of these here.

Step 4: The Stuff You Need


Alright now that you understand the basics of Java, we are ready to download everything we need to code in Java. First off, you'll need the JDK, which stands for "Java Developer Kit". You can download that here:

Next, we'll need an IDE. IDE stands for "Integrated Development Environment" . This is like the Microsoft Word of coding. There are plenty of Java IDEs out there, but some of the more popular one's I've listed below:

https://www.eclipse.org/downloads/ - Recommended, all of my tutorials will be in Eclipse

http://www.oracle.com/technetwork/developer-tools/netbeans/overview/index.html - NOT recommended, NetBeans is a weak IDE overall

http://www.jetbrains.com/idea/download/ - Personally never used it, but has great reviews and is probably better than Eclipse

Step 5: Setting Up

Once everything is installed, open up Eclipse (or the one you downloaded, I am not going to support other IDEs). It will ask you for a default workspace. This is where all of your project files will be stored. I recommend My Documents/ workspace, but you can choose any folder you want. Now that you have set that, there should be a loading bar, once it is done loading, Eclipse will open up. It is probably a lot to take in right now, but I will explain everything in a later tutorial.

Step 6: Making a Project

In order to create a project, you need to click on the button under "File". It should look like a window with a star on it. Click the arrow next to it and select "Java Project" It will open up a window. Put in any name you'd like and press "Finish". Now click the arrow next to your project on the right. A tree menu should open up. Inside should be two items; "src" and "JRE System Library". Right click on "src" and choose New > Class. It should open up a menu. Name it "Main" for now, and click Finish. It should open a window with a few lines of code in it. Now lets make a program! Under "public class Main {" put:

public static void main(String args[]) {
System.out.println("Hello World!");

Lets see what this code does. Press the button on the top that looks like a play button. A window should pop up, select Java Application. It should say "Hello World!" under the Console tab at the bottom. Congratulations! You have just made your first Java application.

Step 7: Sooo... What Does This Mean???

So you got it working! That's all fine and dandy, but do you have any idea on what any of this does? I'm sure you get some of it, but I'll go into detail about this.

public class Main {
This line is the class declaration. Basically what this does is tell Java what your class's name is and what kind it is. "public" means that it can be accessed by other classes. "class" means that....it is a class..... "Main" is the name of your class. And what is the curly bracket at the end??? This tells you what is in the class. So all the code in between this bracket and the last bracket is part of the class.

public static void main(String args[]) {
This is called a method. A main method is needed in order to run a Java Application. This will make more sense in my next tutorial.

System.out.println("Hello World!");
Pretty self explanatory. This is the meat and potatoes of our code and it prints out "Hello World!" "System" is a class that Java uses to gather information about a user's computer (yes, many programs can get a lot of info about your computer with Java). "out" is the output stream of Java. Basically it means to do something to the computer. "println" is short for print line, and you can use it to write data to the console. The semicolon at the end tells Java "This line is done! Stop reading it!". If you don't put the semicolon, it will show up with errors!

This closes the main method and the class. It basically is closing the open brackets.

Step 8: Going on From Here

You now know some basics of Java programming, but this is not even close to how advanced you can get with Java. I challenge you to play around with this class and see what you can do.

Step 9: Final Notes

Thank you for bearing with my tutorial, I hope it was informative, if you have any questions or concerns comment below and I'll answer as soon as I can.

Next Up:


About This Instructable



More by mattrickcode:[Part 2] Intro to Java - Variables [Part 1] Intro to Java - Getting Started 
Add instructable to: