I am trying to cast in Java from string to integer and the other way around but the compiler is complaining about this.
My question is: Is this the matter of compiler or Java programming language doesn't support this kind of casting.
Questions on Programmers Stack Exchange are expected to relate to software development within the scope defined by the community. Consider editing the question or leaving comments for improvement if you believe the question can be reworded to fit within the scope. Read more about reopening questions here.If this question can be reworded to fit the rules in the help center, please edit the question.
You cannot cast since they are different types; the language does not allow you since Java has a very strongly typed system. You can do this however:
In Java you have these types of legal casting:
However in your case you have two distinct classes