Java字符串轉換
String
類有一個重載的valueOf()
靜態方法來獲取任何原始數據類型或任何對象的值的字符串表示。 例如,
public class Main {
public static void main(String[] args) {
String s1 = String.valueOf('C'); // s1 has "C"
String s2 = String.valueOf("10"); // s2 has "10"
String s3 = String.valueOf(true); // s3 has "true"
String s4 = String.valueOf(2014); // s4 has "2014"
}
}