Difference of Type casting in Android and Java -
i m trying write tool testing android apps.
in middle of path, encountered problem in type casting. know type casting parent class 1 of child classes not correct.but don't know in android apps, why can have such thing that?
to clear, have written test java program in eclipse. in "view" class parent , "toolbar" class child extends it.
the problem emerges when try type casting view toolbar.both lines of program make exceptions can see below. how can fix such exception?
package main; import a.view; import b.toolbar; public class aaa { public static void main(string[] args) { // todo auto-generated method stub double x = 2; toolbar t= (toolbar) new view(); toolbar xs = (toolbar) new object(); } } the exception is: exception in thread "main" java.lang.classcastexception: java.lang.object cannot cast b.toolbar @ main.aaa.main(aaa.java:13)
Comments
Post a Comment