将int类型转换成String类型、List的使用和Eclipse插件implementors

本文介绍了在Java中将int类型数据转换为String类型的三种方法:直接使用Integer类的toString方法;通过创建Integer对象再调用其toString方法;利用String类的valueOf方法。并对比了这些方法的特点。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

 

int 类型转换成 String 类型:

 

方法 1 (直截了当,首选):

static String

toString (int i)
          Returns a String object representing the specified integer.

-》这个方法是Integer类中的静态方法,直接将int数据转换成String类型。(20090514追加)

 

 

方法 2 (绕了一圈,备选):

先转换成 Integer ,再转换成 String

 

Integer (int value)
          Constructs a newly allocated Integer object that represents the specified int value.

 

String

toString ()
          Returns a String object representing this Integer 's value.

-》这两个方法也是Integer类中的方法,不如直接使用方法1来得干脆。(20090514追加)

 

 

方法3(20090514追加):

 

使用String类中的valueOf方法,如同方法1,也可以直接将int数据转换成String类型。

static String valueOf (int i)
          Returns the string representation of the int argument.

 

 

 

 

List 的使用:

List list = new ArrayList()

对外暴露的是 List 接口,内部使用的是具体的实现类。

-》这也算是小小的面向接口编程的例子吧(20090514追加)。

 

 

 

一個Eclipse插件implementors——用來從接口快速定位到其實現的插件。

 

-》在NBS项目中,这个插件得到了广泛应用,快速定位,提高效率,很不错。

官网的英文介绍:The Implementors plugins add the possibility to jump to the implementation of of an interface. Alternatively, you can jump to the interface of an implementation.

中文解释:这个Implementors插件添加了从接口跳转到实现类的能力,二选一,你也能够从实现类跳转到接口。

(20090514追加)

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值