Welcome to Java – An Introduction

Welcome to “Welcome to Java”, this is part one of a string of articles about Java, what it is and how to use it. I plan on adding to “Welcome to Java” a couple of times a week. One of the articles will act as a write up from a lesson at University, this article for example, the second article will deal with some more complex areas of Java that I have been teaching myself over the past months.

What is Java?

Java is a popular Object Orientated Language, it is similar to C++ but it has fewer low-level aspects than C++, pointers for example. Java is able to run on any computer that has the correct Java Virtual Machine installed. When compared to C++, which has to be compiled for certain types of processors, this makes Java a very appealing programming Language.

C++ is compiled into Machine code that can only run on the type of computer architecture that it is being compiled for. Java, however, is compiled into bytecode which can be run on the Java Virtual Machine regardless of the computer architecture. Because of this a programmer only has to make an application once for it to work on all devices.

Why use Java?

Java has commonly been the language of choice for the implementation of business applications in large companies. There are many reasons why a team of developers would choose Java as the language they wish to develop their applications in.

Easy to learn

Java is a simple language for a developer to learn, especially if the developer has come from working in a C++ environment. This means that is there is a large group of developers working on a business application it won’t take long to get all developers up to a decent level of competency using Java.

Variety of choice

As a business it is better to use an existing library within their application rather than to develop their own library to do what they need. Fortunately, Java has a vast amount of libraries and frameworks developed by other developers that can be used in an application developed by the company. Another benefit to the the Java “Ecosystem” is the amount of different types of IDE’s that are available to developers. This means that employees within the business are able to use an application that they are familiar with to help them to develop the application.

They are just two of many reasons why Java is a good language to use within a business environment. Java also used outside of a business environment. One prime example of this is the Android Mobile Operating system. The SDK provided by Google to assist with the development of Android apps is written in Java. In turn, this means that most Apps written for Android use Java.

Using Java

The basics

As mentioned above Java is an Object Orientated language, so every piece of code must be contained within a class. Below is an example Java application that would print “Hello World!” into the console when it is debugged.

So what does this code do?

The code is all enclosed within a class “ExampleClass”:

This code alone will not do anything. “ExampleClass” will be where we put our “main” method, this is where the initial code will be run from. As a rule, the “main” method within out application should not do any of the hard work in an application, it should solely be used to declare classes and call methods from these classes. Our application does something really simple and outputs to the console. That’s okay.

The main methods should take an array of Strings as commands. This means that when the application is run from the command line it knows what do with itself. I shall cover that in more detail soon.

Here is the “main” in our example application:

That is a pretty basic application.

Download the zip.

I this gives you a good idea of the background of Java, and an idea of the very basics of Java.

Post a Comment

Your email address will not be published.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>