What function can be used to sort a Vector?

后端 未结 7 2131
故里飘歌
故里飘歌 2020-12-06 09:40

I cant find any sorting function in the java API for vectors. Collections.sort is only for List and not for Vector.<

相关标签:
7条回答
  • 2020-12-06 10:27

    According to the Java API Specification for the Vector class, it implements the List interface which is needed to use the Collections.sort method.

    Also, as a note, for most uses the Vector class could be replaced by using one of the List implementations in the Java Collections Framework, such as ArrayList. The Vector class is synchronized, so unless there is a real need for synchronized access one should use one of the other List implementations.

    0 讨论(0)
提交回复
热议问题