I am a beginner in programming(java) and want to know, how to do typecasting in it. show me by giving examples.

don't double post questions. JamesCherril made it in your other post quite clear why this isn't a 1 + 1 = 2 kind of answer.

for some types, you'll need method a, for some types, you'll need method b, for some types, it's impossible, so please, either give us something we can actually answer to, if you want to know what kind of details we need, I would suggest reading the reply you were given in your other thread in which you asked this question.

if you won't even be bothered to read the answers you are given, than please, stop thinking we will be bothered to try and help you.