Java lang Long.toOctalString()方法与示例
java.lang.Long.toOctalString()方法返回long参数的字符串表示形式,以基数8为无符号整数。
示例
现在让我们看一个例子-
import java.lang.*; public class Main { public static void main(String[] args) { long l = 220; System.out.println("Number = " + l); /* returns the string representation of the unsigned long value represented by the argument in Octal (base 8) */ System.out.println("Octal = " + Long.toOctalString(l)); } }
输出结果
Number = 220 Octal = 334
示例
现在让我们看另一个示例,其中考虑负数-
import java.lang.*; public class Main { public static void main(String[] args) { long l = -55; System.out.println("Number = " + l); System.out.println("Octal = " + Long.toOctalString(l)); } }
输出结果
Number = -55 Octal = 1777777777777777777711