Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

can we cast an array ?

 
saima kanwal
Ranch Hand
Posts: 148
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have the following code :




And this code works perfectly well, which means that i can put a honda in car reference and then cast it and put it in another honda reference. But if i do the same thing with Array it does not work . i get a compiler error. so if i change my car tester class like this :




so can anyone tell me whether casting is possible with arrays? if so then how can i correct my code ?



saima.




 
Rok Ć telcer
Ranch Hand
Posts: 101
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
saima kanwal wrote:
so can anyone tell me whether casting is possible with arrays?

Sure it is.

saima kanwal wrote: if so then how can i correct my code ?

Change the following line:
to

Regards,
Rok
 
saima kanwal
Ranch Hand
Posts: 148
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Rok.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic