what does it mean ? can someone please clarify ?
strong vs. weak typing
This distinction refers to the behavior of the language when values are operated on. In a strongly typed language, operations must match the types of the values operated on (addition must be performed on numbers, for example). In weakly typed languages operations might be made on values which are inappropriate.
echo $variable_three; //will result 25, the string "15" will be automatically casted to integer
echo $variable_four; //will result 20, the interpreter is confused how to handle the string "hallo"
As you can see the weak-type language has its advantages and disadvantages:
1. easier for beginner
2. faster to develop
1. nightmare to debug (especially if it is a large app)
2. give more tolerance for failure or wrong understanding (which could lead to serious security issues)
3. Can be a source of memory/performance hog
This big tolerance for failure which could lead to disaster is also an argument why many say JEE or .Net(C#) is much more scalable than PHP or some other weak-type script languages.
Originally posted by krishna nav:
ex: var a;
here variable "a" can hold char,int,float,etc so many types.
but in Java u need to declare type of variable before using it
& also u cannot directly assign variable of one type into another, u need to do casting.
Originally posted by Daniel Lucas:
When I think of java being a strongly typed language, I think of the fact that I have to type exactly what I want it to do; I can't leave anything up to the compiler to change on its own.
Then you are actually thinking of the wrong thing.
Strong typing just refers to the fact that an object has a type, and that you get a runtime error when you are trying to do something with an object that its type doesn't support.
Static typing means that variables have types, too, and that you get a compile time error when you are trying to do something on a variable that its type doesn't support.
Manifest typing means that you have to actually explicitely declare the type of each variable.
Java is both strongly, statically and manifestly typed.