Link to home
Start Free TrialLog in
Avatar of Manikandan Thiagarajan
Manikandan ThiagarajanFlag for India

asked on

generics problemis to avoid type cast problem is i correct

generics  problemis to avoid type cast problem is it correct

any way explain advanages of generics
Avatar of Am P
Am P
Flag of India image

ASKER CERTIFIED SOLUTION
Avatar of kaufmed
kaufmed
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Generics' intention is to avoid type cast problems during runtime . By using generics , you can strictly specify with which types you want your routine to work . The compiler restricts clients(callers) to use the routine by passing only those types  and nothing else . Thus , compiler makes that type checking instead of the runtime . So ,if you have any bad callers , then it is detected at compile time instead of ending up with a surprise at runtime.
Avatar of Manikandan Thiagarajan

ASKER

is it jdkk1.5 feature or jdk1.6 features
I'm sure you'd agree that we can use the function defined immediately above because it is designed to take in only ints.
That was supposed to say "can not" in my comment.
is it jdkk1.5 feature or jdk1.6 features
According to Wiki, they came with Java 5.