【发布时间】:2016-04-28 20:17:49
【问题描述】:
我有一个字符串,它返回一组由; 分隔的 id。我正在拆分它们以获取它们各自的值以传递给另一个实用程序以查找父 ID。然后,我需要将父 ID 相互比较以确保所有 ID 都是相同的值。字符串可以包含一对多的 id。示例:
String unitIdList = "3e46907f-c4e8-44d2-8cab-4abb5a191a72;9d242306-1c7c-4c95-afde-e1057af9d67c;2e96838f-f0df-4c82-b5bc-cb81a6bdb792;b21a4b19-6c1a-4e74-aa84-7900f6ffa7a8"
for ( String unitIds : unitIdList.split(";") ) {
parentId = UnitUtil.getInstance().getParentId(UUID.fromString(unitIds));
// now I need to compare parentIds. They should all be the same, but if not then do something else.
}
如何比较每个值?
【问题讨论】:
标签: java string split compare java-7