提示:您可在线编辑运行本教程的实例 - 运行实例,去试试!
- static String valueOf(int i) Converts argument int to String
- static String valueOf(float f) Converts argument float to String
- static String valueOf(long l) Converts argument long to String
- static String valueOf(double i) Converts argument double to String
- static String valueOf(char c) Converts argument char to String
- static String valueOf(boolean b) Converts argument boolean to String
- static String valueOf(Object o) Converts argument Object to String
public class Main { public static void main(String args[]){ /** N o w J a v a . c o m **/ int i=110; float f = 110.0f; long l = 110; double d=110.0d; char c='a'; boolean b = true; Object o = new String("Hello World"); /* convert int to String *//* from N o w J a v a . c o m - 时 代 Java*/ System.out.println( String.valueOf(i) ); /* convert float to String */ System.out.println( String.valueOf(f) ); /* convert long to String */ System.out.println( String.valueOf(l) ); /* convert double to String */ System.out.println( String.valueOf(d) ); /* convert char to String */