我创建了一个Vector对象来存储Table
对象中的数据,如Vector<Table>
。 Vector<Table>
包含如下组件。向量排序JAVA
[Vector<Record> records, String tableName, String keyColumnName, int recordCount, int columnCount]
我需要在上述载体排序tableName
我自己的订单,并与sorted tableNames
返回Vector<Table>
其他进程。
我怎么能这样做?
修订
我有如下写道方法。
private Vector<Table> orderTables(Vector<Table> loadTables) {
ArrayList<String> tableNames = new ArrayList<String>();
for (Table table : loadTables) {
String tblName = table.getTableName();
tableNames.add(tblName);
}
Collections.sort(tableNames, new MyComparable());
return null;
}
但我不知道怎么写Comparator
这个想法。我自己的排序顺序存储在.properties
文件中。我可以阅读它并获得价值。但我不知道如何比较它。
我该怎么办?
而另一个建议:避免使用'VECTOR'。使用任何其他'List'实现('ArrayList','LinkedList'等)供您选择。 – AlexR
@AlexR,@aioobe:我更新了我的问题。我不知道如何编写“比较器”。我研究了一些从谷歌搜索中找到的例子。但我无法为我的必要写一个“比较器”。 – Bishan