What function can be used to sort a Vector?

后端 未结 7 2145
故里飘歌
故里飘歌 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:09

    Collections.sort(vector_name)

    It'll sort the vector in place, so you don't need to assign the result of the above command back to the vector.

    This works because Vectors are implementations of Lists.

提交回复
热议问题