• Post Reply Bookmark Topic Watch Topic
  • New Topic

Sorting of Collections  RSS feed

 
Gajendra Tomer
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

My Query is related to below code:



At Line #1 compiler gives following warnings:

1)"UnChecked call to add(E) as a member of the raw type java.util.Vector
2)Unchecked conversion found: java.util.Vector
required:java.util.List<T>

How can we make this warning free?
 
Sridhar Santhanakrishnan
Ranch Hand
Posts: 317
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can you give more details about your comparator implementation(myComparator)?

The following code runs just fine without any compile or runtime errors.

 
Vijitha Kumara
Bartender
Posts: 4002
42
Chrome Fedora Hibernate
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Sridhar Santhanakrishnan:

The following code runs just fine without any compile or runtime errors.



You are right But It's not the errors OP is talking about. Compiler Warnings !!
Here your add operation should give one warning if you are using JDK 5 or above since Vector is not declared as typed (this case Integer). Should be



And the 2nd Warning because sort method's signature is



You may go through the API for Collections class.
 
Sridhar Santhanakrishnan
Ranch Hand
Posts: 317
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry my mistake, My compiler levels are set to 1.4
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!