我正在尝试根据两个字段 [ Name , Old name ] 按升序对对象列表进行排序,其中Name字段值可以是破折号(“-”),如果名称是破折号,那么它将被添加到列表的末尾. [像下面的顺序:名称:旧名称]
SENSITIVE: COMP Operations: COMP Operations
SENSITIVE: Court procedural documents: Court procedural documents
SENSITIVE: Staff matter: Staff Matter
SPECIAL HANDLING: ETS Critical: ETS Critical
-: ETS Limited
-: EU Satellite Navigation matters
-: Limited ETS Joint Procurement
到目前为止,我得到了以下结果:
-: ETS Limited
-: EU Satellite Navigation matters
-: Limited ETS Joint Procurement
SENSITIVE: COMP Operations: COMP Operations
SENSITIVE: Court procedural documents: Court procedural documents
SENSITIVE: Staff matter: Staff Matter
SPECIAL HANDLING: ETS Critical: ETS Critical
领域模型:
class Marking {
String name;
String oldName;
public Marking(String name, String oldName) {
this.name = name;
this.oldName = oldName;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getOldName() {
return oldName;
}
public void setOldName(String oldName) {
this.oldName = oldName;
}
@Override
public String toString() {
return "Marking [name=" + name + ", oldName=" + oldName + "]";
}
}
和解决方案类:
public class Solution {
public static void main(String[] args) {
List<Marking> markings = new ArrayList<>();
markings.add(new Marking("-", "Limited ETS Joint Procurement"));
markings.add(new Marking("-", "EU Satellite Navigation matters"));
markings.add(new Marking("SENSITIVE: Court procedural documents", "Court procedural documents"));
markings.add(new Marking("SENSITIVE: COMP Operations", "COMP Operations"));
markings.add(new Marking("-", "ETS Limited"));
markings.add(new Marking("SENSITIVE: Staff matter", "Staff Matter"));
markings.add(new Marking("SPECIAL HANDLING: ETS Critical", "ETS Critical"));
任何人都可以给我一些建议,如何将破折号名称对象添加到列表的末尾,其中旧名称应按升序排列。
吃鸡游戏
缥缈止盈
相关分类