是否经常使用包装类提供的静态方法? [英] Are static methods offered by wrapper classes often used?

查看:25
本文介绍了是否经常使用包装类提供的静态方法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我很好奇包装类的静态方法是否真的有用.

I'm curious if static methods of wrapper classes are really helpful.

哪些是最有用和最常用的?你能介绍一下涉及这些方法的任何必须知道的技巧吗?

Which of them are most useful and popularly used? Can you present any must-know tricks involving these methods?

提前致谢.

推荐答案

compare 方法可用于处理原始对应项.

The compare methods are useful to handle the primitive counterparts.

static int  compare(primitive p1, primitive p2) 
          Compares the two specified primitive values.

可能的用途:

@Override
public int compareTo(MyClass other){
    return Double.compare(this.myDoubleField, other.myDoubleField);
}

这篇关于是否经常使用包装类提供的静态方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆