Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Best way to do generics?  RSS feed

 
Kousik Majumder
Ranch Hand
Posts: 241
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

I have a query. Suppose I have code for java 1.4 as below.



I want to make it generic to comply with Java 1.5

What is the best way and why?

a)
or
b)
 
Campbell Ritchie
Marshal
Posts: 55751
163
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If the code works, why do you need to change it?
 
Kousik Majumder
Ranch Hand
Posts: 241
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
it is the requirement. That is why.
 
Rob Spoor
Sheriff
Posts: 21092
85
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are the map values instances of Comparable<Object> I'd say probably not. String for instance isn't, it's Comparable<String>.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!