Either in C or Java, when a variable is declared, it must be informed to the compiler what data type the variable stores like integer, float, double or string etc. Observe the following variable declaration in Java.
int marks = 20. String str = "way2java.com"; boolean raining = true;
The variable must be declared along with the data type. Similarly, an array object must be instantiated with the size. This is a feature of strongly typed languages.
var marks = 20. var str = "way2java.com"; var raining = true;
It looks nice and easy with loosely typed languages. But I feel it raises a lot of problems in coding. Observe the following.
Say in Java language:
int cost = 10; int cost = 20;
It is compilation error as two times cost is initialized. You must declare only ones and can be reassigned number of times as follows.
int cost = 10; cost = 20;
var cost = 10; var cost = 20;
A strongly typed language compiler enforces strict rules over the operations, what programmer can do, on data types and also passing parameters and return type to a method. An advantage of strongly typed language is it gives consistency over the results (by declaring the variables with data types). Specific operations are allowed on certain types. For example boolean cannot be used in addition, but an int can be used in addition. Boolean is used in control structures. This type of accidental wrong coding raises error by a strongly typed language.