Although there are so many questions related to this topic but somehow i always feel that something i don't know or say i am not satisfied with those answers, so here i post again
Integer in=new Integer(4);
Character character=(Character) in; //Cannot cast from Integer to Character
String s="hello";
int j=(int) s;//Cannot Cast from string to int
char chi='a';
int l=(int)chi; //works
int i=0;
char ch=(char)i; //works
String b=(String)1+"hello";//cannot cast from int to string
in the 2nd,4th and 9th line it shows me the commented error whereas i can make the conversion between int and char in the line where it is commented works.
So in the code that i have posted where the compiler checks for the static/dynamic behavior and where it check for the weak/strong behavior.
I am sure there must be so many answer of these question would be available so if available post the link otherwise detailed explanation would be really appreciable.
What makes me confused
- Some how both Static/Dynamic and Strong/Weak looks same to me
- How the compiler understand when to check for the Static/Dynamic types and when to check for the Strong/Weak types
- What are the necessity of the two kind of type checking system.