出乎我的意料之外, 原來 long 轉 string 用 + 符號就可以了, 呵呵.
Using + operator
long var = 123L;
String str = var+""; // str is '123'
Long.toString()
long var = 12345L;
String str = Long.toString(var);
System.out.println(str); //prints '12345'
這個偶爾會用錯, 變成 Long(var).toString();
Long constructor with long argument has been deprecated in Java 9, but you should know it.
原來古時候, 是可以的.
String.valueOf()
long l = 12345L;
String str = String.valueOf(l); // str is '12345'
String.format()
long l = 369L;
String s = String.format(“%d”, l);
這些都沒有加號好用和直覺呀, 呵呵.