Saturday 18 March 2017

A Simple Java Program

Program: 
import java.lang.*;

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


Classes and Objects
A Class is something that defines a particular behavior or a trait or your actions.
I belong to the class Human.
I can talk, walk on two legs, operate a computer like any other Human can.
So I am an object of class Human,


Now, Snowy, from Tintin is an object of the class Dog.

Here, we have a main class HelloWorld which prints the message "Hello World...".

We have a main method. The main method is where the execution of the program starts.
So when you execute your program the first thing to be executed would be the System.out.println also known as the "Sout" statement. And what the "Sout" statement does is It prints to the console.
Why does it do so?

Because, it is instructed to by the JVM, the JAVA VIRTUAL MACHINE.

I will explain what the API is later but remember everything in Java is there in the Application Programming Interface. It is like a dictionary which helps you translate what you want to do in the programming language. It tells you what to put in, to get the output you desire.

Types of applications:
1. Console Applications: These are the applications that allow you to use the command line interface that is the command prompt in your windows to take input and to print the output.

2. Windows Applications: These are the GUI based applications. By GUI I mean Graphical User Interface. So, Java allows you to create applications like notepad or whatever applications we use in the windows operating system. You can develop windows applications either by using AWT(Abstract Window Toolkit) or Swing.

3. Web Applications: These can be accessed by the web browser. This blog that you view in chrome or any other browser. The websites that we access are also examples of web applications. Java has support for creating applications that work with HTML and allows you to create web applications. 

4. Mobile Applications: Java gives you J2ME which is the Java 2 Micro Edition. The API helps you develop mobile applications with ease. And also gives you a variety of controls for developing your application. IDEs like Netbeans comes with a simulator so that you can simulate and test how your mobile application would actually work on a mobile phone.

5. Enterprise Applications: You can develop enterprise applications using EJB(Enterprise Java Beans). It is a part of the J2EE, the Java 2 Enterprise Edition.