• Post Reply Bookmark Topic Watch Topic
  • New Topic

Interface explanation  RSS feed

 
Kishor Joshi
Ranch Hand
Posts: 674
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi there

I have Created an Interface




and here is my implementation class



but at the output it only shows blank scrren no 0,1,-1 there

why?


Thanks
 
Paul Clapham
Sheriff
Posts: 22828
43
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can you point to the code which you think ought to write something to the console? It sounds like you were expecting that.
 
Kishor Joshi
Ranch Hand
Posts: 674
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
sorted out i made some change and it works now
 
Campbell Ritchie
Marshal
Posts: 56536
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A method called isLargerThan should not return an int. It should return a boolean.

I cannot work out how you are going to implement that method. I think your interface should be Relatable<T> the way Comparable is Comparable<T> and the method's parameter should be T.
Then you can write things like… and have it go horribly wrong when you write this sort of thing:-
 
Campbell Ritchie
Marshal
Posts: 56536
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What changes did you make? In the Rectangle class you appear simply to have duplicated Comparable which I told you about earlier. That would have been a correct implementation ten years ago before generics was introduced, but nowadays you would use generics (as I showed earlier) to obviate that error‑prone cast. You can find all the changes you need of you go through my previous post.

Only use org.kishor in package names if you own the website www.kishor.org.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!