Class 0: Hello World

Hello, my name is Farai Gandiya. I’m a college student at from Zimbabwe and I study at Wartburg College in Iowa as a Computer Science major. I’m taking is a language workshop in the Java Programming Language.

I choose to learn Java is because of its significance in the programming world. Android Applications are written in Java. Minecraft Classic was written in Java, allowing it to run on Windows (not 10),OS X and Linux. Some websites/web applications implement their back-ends in Java, such as Twitter with the Java derivative Scala.

Java also has interesting topics worth knowing about. Being a purely object-oriented language, everything is an object, meaning that programming is different from other languages. It’s also statically types, meaning that one has to be deliberate with the inputs and outputs of methods. Object-orientation and static typing are really different from other languages I have programmed in, like Python and JavaScript.

Over the next couple of weeks, I will post an article of the things I’m learning in Java on this blog. I have another blog, The Algorithmic Cookbook, for more articles.

To run java apps, I’ll using the DrJava IDE to write, compile and execute the program. To use it, you need to have the Java Runtime Environment since Dr Java is written in Java!

So, without further a do, here’s the ceremonious Hello World example in Java.

public class HelloWorld{   
   public static void main(String[] args){
  System.out.println("Hello World");
}
}
  • public means that all files can access the class
  • static means that there will only be one instance of the main method in shared across all the files that make use of it
  • void means that the method does not return anything
  • String[] args allows the Java file to take commands (known as arguments) through the command line.
  • System.out.println() prints the stings inside the parentheses on a separate line.

To see this code in action, see this.


Edit January 11: I decided that it would me more appropriate to use Class instead of week for the title. Also, I added a part on how to run the program.

Advertisements