Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

interface implementation

 
neha. bajaj
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
 
neha. bajaj
Ranch Hand
Posts: 31
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Oops.. hadn't implement interface
 
Winston Gutkowski
Bartender
Pie
Posts: 10417
63
Eclipse IDE Hibernate Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
neha. bajaj wrote:Oops.. hadn't implement interface

So, that's settled is it? I didn't see a question.

Winston
 
Matthew Brown
Bartender
Posts: 4567
8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think the implied question was "why is this implementation allowed when the return type is wider?".
 
neha. bajaj
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Matthew Brown wrote:I think the implied question was "why is this implementation allowed when the return type is wider?".

I don't think widening is working here.I tried but byte is not subtype of int but Byte is subtype of Number.
 
Winston Gutkowski
Bartender
Pie
Posts: 10417
63
Eclipse IDE Hibernate Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
neha. bajaj wrote:I don't think widening is working here.I tried but byte is not subtype of int but Byte is subtype of Number.

How is converting an int to a byte widening?

My suggestion: explain what you want to do, and ask a question; and we might be able to help.

Winston
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Posts: 15272
37
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
byte is not a subtype of int, and long is not a supertype of int - there's no inheritance relationship between the primitive types.
 
Sirajuddin Khan
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
neha. bajaj wrote:


for your kind information, please check your code because it is not implement the interface's method so you got compile-time error.
You are doing overloading....
 
Winston Gutkowski
Bartender
Pie
Posts: 10417
63
Eclipse IDE Hibernate Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sirajuddin Khan wrote:please check your code...

Sirajuddin,

Please don't post very long lines in code. I broke yours up this time and I suggest you re-read the UseCodeTags page thoroughly.
This applies whether you are posting your own code or somebody else's.

Thanks.

Winston
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic