• Post Reply Bookmark Topic Watch Topic
  • New Topic

Constructor call using super()  RSS feed

 
Gajendra Kangokar
Ranch Hand
Posts: 94
1
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi friends,
in the below code i am getting compiler error at Line 6.


It says to create constructor in Animal that accepts int type.but how do i call constructor that accepts byte type?
Thank you
 
Shashank Gollapudi
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rest everything like add, remove etc are from the Collection interface which List interface extends
 
Khuzema Dharwala
Ranch Hand
Posts: 61
Java Linux Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Change the call to super like below




In java by default integer primitives are considered as int hence implicit cast will not work here as going from int (large container) to byte (short container) will be a loss of precision and compiler sense that so explicit cast to byte is needed.


Thanks.....
 
Gajendra Kangokar
Ranch Hand
Posts: 94
1
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you Khuzema!!
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!