Win a copy of Machine Learning Systems: Designs that scale this week in the Scala forum
or Xamarin in Action: Creating native cross-platform mobile apps in the Android forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Constructor call using super()  RSS feed

 
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
 
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
 
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!!
 
Good heavens! What have you done! Here, try to fix it with this tiny ad:
Rocket Oven Kickstarter - from the trailboss
https://coderanch.com/t/695773/Rocket-Oven-Kickstarter-trailboss
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!