什么是Java相当于.NET的IEquatable&LT的; T>接口?接口、NET、Java、IEquatable

2023-09-03 15:53:26 作者:仙女味的小巫女

什么是Java相当于.NET的IEquatable接口?

What is the Java equivalent of .NET's IEquatable Interface?

推荐答案

不幸的是,我不相信有一个 - 这是在提供哈希映射等定制的相等比较而言痛苦:(

Unfortunately I don't believe there is one - which is a pain in terms of providing hash maps etc with custom equality comparisons :(

显然有可比< T> 作为等同于 IComparable的< T> 比较< T> 的IComparer< T> ,但我不相信有任何相等于的IEqualityComparer< T> IEquatable< T>

Obviously there's Comparable<T> as an equivalent to IComparable<T> and Comparator<T> for IComparer<T>, but I don't believe there's any equivalent of IEqualityComparer<T> and IEquatable<T>.

有可能是第三方库提供相同的排序界面和地图的哪些使用,当然他们......

There may be third party libraries providing the same sort of interface and maps which use them of course...