問題網址:https://www.hackerrank.com/challenges/java-int-to-string/problem
問題重點:型別轉換函數
查詢API Java.lang class Integer 輸出String
static 方法 使用: 類別名稱.方法名稱();
https://docs.oracle.com/javase/7/docs/api/java/lang/Integer.html
toString
public static String toString(int i)
Returns a String object representing the specified integer. The argument is converted to signed decimal representation and returned as a string, exactly as if the argument and radix 10 were given as arguments to the toString(int, int) method.Parameters:i – an integer to be converted.Returns:a string representation of the argument in base 10.
解答: String s = Integer.toString(n);