Topic: int 怎么转换成String类型的?

  Print this page

1.int 怎么转换成String类型的? Copy to clipboard
Posted by: 风飘尘
Posted on: 2006-09-10 01:53

请各位高手指教!!

2.Re:int 怎么转换成String类型的? [Re: 风飘尘] Copy to clipboard
Posted by: 风飘尘
Posted on: 2006-09-10 01:54

zcjl wrote:
String.valueOf(int i)


谢谢啦!!
我去看看

3.Re:int 怎么转换成String类型的? [Re: 风飘尘] Copy to clipboard
Posted by: Stub
Posted on: 2006-09-10 02:33

int iii = 100;
String str = Integer.valueOf(iii).toString();
System.out.println(str);

4.Re:int 怎么转换成String类型的? [Re: 风飘尘] Copy to clipboard
Posted by: leange
Posted on: 2006-09-10 19:11

最简单也是推荐方法:

int a = 1;
String b = ""+a;

5.Re:int 怎么转换成String类型的? [Re: leange] Copy to clipboard
Posted by: stevendu
Posted on: 2006-09-11 17:30

leange wrote:
最简单也是推荐方法:

int a = 1;
String b = ""+a;


这怎么会是推荐的方法?
推荐的是:String.valueOf(int i);

6.Re:int 怎么转换成String类型的? [Re: 风飘尘] Copy to clipboard
Posted by: coolcool1265
Posted on: 2006-10-08 10:18


/**
* @(#)str_valu.java
*
*
* @author luoqi003
* @version 1.00 2006/10/8
*/

public class str_valu {

/**
* Creates a new instance of <code>str_valu</code>.
*/
public str_valu() {
}

public static void main(String[] args) {
int i=100;
// String str=Integer.valueOf(i)toString();*********something wrong???
String str=""+i;
System.out.println(str);
}
}

why if I use
‘ String str=Integer.valueOf(i)toString();*********something wrong??? ’

7.Re:int 怎么转换成String类型的? [Re: coolcool1265] Copy to clipboard
Posted by: why
Posted on: 2006-10-08 11:51

coolcool1265 wrote:
why if I use
‘ String str=Integer.valueOf(i)toString();*********something wrong??? ’

Integer.valueOf(i).toString()

8.Re:int 怎么转换成String类型的? [Re: 风飘尘] Copy to clipboard
Posted by: q_yuan
Posted on: 2006-10-09 17:08

简单一点吧。用这个就可以了String.valueOf(int i)

9.Re:int 怎么转换成String类型的? [Re: 风飘尘] Copy to clipboard
Posted by: jameszhang
Posted on: 2006-10-10 22:32

JAVA 的8 个基本类型,每个都有一个包装类,int 的 是Integer,关于int 的操作应该到 Integer 中去找 ,对象的 toString() 不应该是解决办法、

10.Re:int 怎么转换成String类型的? [Re: 风飘尘] Copy to clipboard
Posted by: fat32
Posted on: 2006-10-10 22:51

为什么不用Integer.toString(int i)


   Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent
Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1
客服电话 18559299278    客服信箱 714923@qq.com    客服QQ 714923