How To - Java Hello World

Hey guys, new year, new motivation, new yay.
This is the start of my How To Java - so let's go :D

When you start with any programming language and the additional self-t(orturing)eaching lecture, they will introduce you with this exercise

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

This non-humanity-threatening message is all cute 'n' shit but what exactly does it mean?
This is already a fully functional program, so you deserve to be proud of yourself, but let's break this down:

The first line in your code is usually gonna be your class name. Names are important, it is how you will later on find your program (or class) after you stored it away in your workspace somewhere, to incorporate it into a more complex program. 
So class name here is HelloWorld.
The curly bracket after your class name opens up to the body of your program - very good to remember will be how many of those brackets you open - because it is very important to close all of them later on.

Our program here has in total 10 brackets (4 curly ones, 2 square and 4 round ones), and they contain information about WHAT this program is made up of, and WHAT it is supposed to DO.

The line public static void main(String[] args) is what makes our class an autonomous functional program.
When you use this program HelloWorld by running it, your computer basically is looking for this line in context with your class name.

System.out.println("Hello World"); is what our program does - you are telling your program to print the message Hello World out and execute this and every other demand you ever program with an ";" at the end of every command.

Additional Knowledge:
public describes the accessibility of the class, there is also private and protected.
static means that the variable or method marked as such is available at the class level.void is the return value.
main(String[] args) is the main-method, our line which makes this a program :D
The words before it just are its attributes.

Don't worry you don't need to know all of this in detail (yet).


Popular posts from this blog

How To - CYK Algorithm

How To - Citric Acid Cycle

How To -Glycolysis - Biochemistry