First Program in Java

Software Requirements:
1. Java Development Kit Download JDK from here
2. A Text Editor, Notepad is good, but we will prefer Textpad or Notepad++ Download Textpad from here


Before designing your first program, note that Java is Object Oriented Programming Language. If you don;t knows the concept of Oops, NO PROBLEM, but you should know the concepts of Object.
What is an Object?
In this world each and everything is an Object. No working (functioning) is perform automatically. Each working is done by some Object.
Same in Java, each and every functioning is associated with some Object. Each Object perform its own work and No Object perform 2 or more works at a time.
Mobile, Chair, Computer, Teacher, Student, Tree, Tiger all are Objects.
Have you seen any Animal?
Yes, dog, cow, tiger.. etc.
But I am sorry to say no one has saw animal. Animal is a classification of similar type of Objects, like tiger,cow,dog etc. Table is not an animal.
You can also say that Animal is the data type of tiger, cow, and dog.
Animal dog,cat,tiger;
Now you says that we have heard about int,long float,double, not Animal; animal is not a data type. OK
let's take one more example
int x,y,z;
We have three variable x,y,z of type int(eger). Now please tell me you will use 'int' or x,y,z? You will use x,y,z, you assign the values to the x,y,z, print them, use in calculations, etc. Then why you are using 'int', exactly 'int' is data type of x,y,z, which tells us the common features of the x,y,z. But exactly x,y,z are in memory not 'int'.
Similarly cow,dog,tiger are physical entities, not 'Animal', 'Animal' is the data type of dog,cat and tiger. Which tells us that these all are animals becuase they have some common featuers of Animal.
Now to create the data type 'Animal' just declare a class(Classification of similar type of objects) and mention the feature/properties of the Animal in the class.e.g.

class Animal
{
   int height;
   int weight;
   String color;
}

All Memory Allocations are runtime in Java. There is NO compile time memory allocations in Java and we have two types of data types.
1. Primitive Data Types- Value Types e.g. byte,short,int etc.
2. Class Type or User Define Data Types- Reference Types (You can also say Pointer types)
But Java is pointerless?, yes Java is pointerless, you can't access the address, you can't manipulate the address, but this does not means that there is no concept of addresses. Java uses addresses internally.
Just remember one simple concept. 8 Primitive data types are values types, and other than these 8 all are reference types i.e. All Class Type variables are reference types.

Animal cat,dog,cow;

Here cat,dog and cow are reference variables, not the Objects.

Now create Objects
cow=new Animal();
dog=new Animal();
cat=new Animal();
new keyword is used for memory allocations. It will allocate the memory to the 3 Animals to store height,weight and color.

If we have 3 different objects of animals, means we need 3 different locations to store the 3 different heights of animals, similarly for weight and color.
Now we can store the properties of the animals using "." notation.
cow.height=4;
cow.weight=150;
cow.color="white";
dog.height=2;
dog.weight=20;
dog.color="black";
cat.height=1;
cat.weight=5;
cat.color="brown";