Java programming lesson 1

in #programming7 years ago

Is programming your passion and do you want to learn the basics of programming? or are you a programmer and you just want to refresh your basic knowledge about programming, than these lessons are for you. This will be the first out of many more lessons to come. In these posts I will take you through the basics of Java programming. I will explain about variables, operators, decision making and classes etc. Lets begin.

Understanding Java

Java is an OOP (Object Oriented Programming) language. Java was brought to life in 1996, the same year I was born :). Maybe that is the reason why I love it so much. OOP programming, simply explained, means that you see everything in objects, just like the real world. So you divide your code into separate objects and place different objects together to make a program. You actually make reusable parts. Java was a language made by Sun Microsystems and later it was bought from Sun Microsystems by Oracle. Since Java was brought to life, it only grew to a better and a more used language. Still Java is used by many companies, to build Android apps, webapps or simple desktop apps.
Java has a very nice philosophy WORA. Which stands for Write Once Run Anywhere. Java is a language where you need to write more code in order to get something to work, but I can tell that it is worth it, because you feel more satisfied. Lets get a look at the first lines of code.

Beginning

After you have installed your favorite IDE, Netbeans, Intellij or Eclipse, you can start by creating a new project and start writing some code. The first line of code you will see most of the time, is the well known, "Hello World".  For some difference I made it a bit different.
// The first line of code
public class Main {
   public static void main(String[] args) {
       System.out.println("Hello world from Java "); // Prints out Hello world
   }
}

So if you have never ever seen code before, you might be a bit overwhelmed by what you see. I will try and explain it. For now, only remeber System.out.println("Hello world"). By using this, you can print out some text and this text will be visible in the console.

As you can see in the console, you see a hello world message appear. Try to play around and print some more messages to the console. 

Links

If you have no IDE you can download them from the following URL's:
https://netbeans.org/downloads/
https://www.jetbrains.com/idea/download/#section=windows
http://www.eclipse.org/downloads/
If you want to run Java on your machine, you need to install the Java JDK(Java Development Kit). You can download the JDK from:
http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html

In this lesson you learned how to print out some text in Java. This lesson was more focussing on getting comfortable with the envoirment. Don't be afraid to write more text to the console. In the following lessons we will learn more things.