Scala Int toHexString() 方法与示例
toHexString()方法用于返回指定整数值的十六进制形式。
Method Definition: def toHexString: String
Return Type: It returns the Hexa decimal form of the specified integer value.
示例 #1:
// Scala program of Int toHexString()
// method
// Creating object
object GfG
{
// Main method
def main(args:Array[String])
{
// Applying toHexString() method
val result = (5).toHexString
// Displays output
println(result)
}
}
输出:
5
示例 #2:
// Scala program of Int toHexString()
// method
// Creating object
object GfG
{
// Main method
def main(args:Array[String])
{
// Applying toHexString() method
val result = (18).toHexString
// Displays output
println(result)
}
}
输出:
12