用String 类的静态方法copyValueOf(char[]data) 例: class Char2String { public static void main(String[] args) { char[] a = {'a','b','c'}; String sTest = String.copyValueOf(a); System.out.println(sTest); } }
也可以象 luckycat(潘鑫)所说,用String 类的构造方法,直接生成
public String(char[] value) Allocates a new String so that it represents the sequence of characters currently contained in the character array argument. The contents of the character array are copied; subsequent modification of the character array does not affect the newly created string. Parameters: value - the initial value of the string.
String str=new String(ch);
例:
class Char2String
{
public static void main(String[] args)
{
char[] a = {'a','b','c'};
String sTest = String.copyValueOf(a);
System.out.println(sTest);
}
}
Allocates a new String so that it represents the sequence of characters currently contained in the character array argument. The contents of the character array are copied; subsequent modification of the character array does not affect the newly created string. Parameters:
value - the initial value of the string.
不是什么时候char,string型都能转成int型的.
只有char,string是0,1,2,3,4,5,6,7,8,9或者这些组合的时候才行的
Integer.parserInt(String.valueOf(Char c));