⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 comparator.java

📁 JAVA 语言的函数式编程扩展
💻 JAVA
字号:
/*                     __                                               *\**     ________ ___   / /  ___     Scala API                            ****    / __/ __// _ | / /  / _ |    (c) 2006-2007, LAMP/EPFL             ****  __\ \/ /__/ __ |/ /__/ __ |    http://scala-lang.org/               **** /____/\___/_/ |_/____/_/ | |                                         ****                          |/                                          **\*                                                                      */// $Id: Comparator.java 12003 2007-06-13 12:14:15Z mihaylov $package scala.runtime;/** *  @author  Gilles Dubochet *  @author  Martin Odersky *  @version 1.2 */public class Comparator {    /** A rich implementation of the equals method that overrides the default     *  equals because Java's boxed primitives are utterly broken. This equals     *  is inserted instead of a normal equals by the Scala compiler (in the     *  ICode phase, method <code>genEqEqPrimitive</code>) only when either     *  side of the comparison is a subclass of <code>AnyVal</code>, of     *  <code>java.lang.Number</code>, of <code>java.lang.Character</code> or     *  is exactly <code>Any</code> or <code>AnyRef</code>, but when both sides     *  have different types. */    public static boolean equals(Object a, Object b) {        if (a == null)            return b == null;        if (b == null)            return false;        if (a.equals(b))            return true;        final long left =            (a instanceof Integer) ? ((Integer)a).intValue() :            (a instanceof Character) ? ((Character)a).charValue() :            (a instanceof Long) ? ((Long)a).longValue() :            (a instanceof Byte) ? ((Byte)a).byteValue() :            ((Short)a).shortValue();        final long right =            (b instanceof Integer) ? ((Integer)b).intValue() :            (b instanceof Character) ? ((Character)b).charValue() :            (b instanceof Long) ? ((Long)b).longValue() :            (b instanceof Byte) ? ((Byte)b).byteValue() :            ((Short)b).shortValue();        return left == right;    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -