爪哇龙。toHexString()方法

爪哇。朗,朗。toHexString()是Java中的一个内置函数,它将长参数的字符串表示形式返回为基数为16的无符号整数。函数接受单个参数作为长数据类型的参数。

null

语法:

public static String toHexString(long num)

Parameters:  The function accepts a single mandatory parameter 
num -  This parameter specifies the number which is to be converted to Hexadecimal string. 

返回值: 该函数将长参数的字符串表示形式返回为基数为16的无符号整数。

例如:

Input : 11
Output : b

Input : 12
Output : c

项目1: 下面的程序演示了函数的工作原理。

// Java program to demonstrate working
// of java.lang.Long.toHexString() method
import java.lang.Math;
class Gfg1 {
// driver code
public static void main(String args[])
{
long l = 11 ;
// returns the string representation of the unsigned int value
// represented by the argument in binary (base 2)
System.out.println( "Hex string is " + Long.toHexString(l));
}
}


输出:

Hex string is b

项目2: 下面的程序演示了函数的工作原理。

// Java program to demonstrate working
// of java.lang.Long.toHexString() method
import java.lang.Math;
class Gfg1 {
// driver code
public static void main(String args[])
{
long l = 234 ;
// returns the string representation of the unsigned int value
// represented by the argument in binary (base 2)
System.out.println( "Hex string is " + Long.toHexString(l));
}
}


输出:

 Hex string is ea
© 版权声明
THE END
喜欢就支持一下吧
点赞12 分享