tooctalstring
整數類toOctalString()方法 (Integer class toOctalString() method)
toOctalString() method is available in java.lang package.
toOctalString()方法在java.lang包中可用。
toOctalString() method is used to represent an octal string of the given parameter [value] of integer type as an unsigned integer in base 8.
toOctalString()方法用于將整數類型的給定參數[value]的八進制字符串表示為以8為底的無符號整數。
toOctalString() method is a static method, it is accessible with class name too and if we try to access the method with the class object then also we will not get an error.
toOctalString()方法是一個靜態方法,也可以使用類名進行訪問,如果我們嘗試使用類對象訪問該方法,那么也不會出錯。
toOctalString() method does not throw an exception at the time of conversion from integer to an octal string.
從整數轉換為八進制字符串時, toOctalString()方法不會引發異常。
Syntax:
句法:
public static String toOctalString (int value);
Parameter(s):
參數:
int value – represents the integer value to be converted.
int value –表示要轉換的整數值。
Return value:
返回值:
The return type of this method is int, it returns the octal string of the given parameter that represent the unsigned integer value.
此方法的返回類型為int ,它返回給定參數的八進制字符串,該字符串表示無符號整數值。
Example:
例:
// Java program to demonstrate the example
// of toOctalString (int value) method of Integer class
public class ToOctalStringOfIntegerClass {
public static void main(String[] args) {
// Variables initialization
int i1 = 10;
int i2 = 20;
int i3 = 30;
int i4 = Integer.MAX_VALUE;
int i5 = Integer.MIN_VALUE;
// Integer instance creation
Integer value = new Integer(i1);
// It represents Octal string of the given
// integer type i2 argument
String s = value.toOctalString(i2);
// Display Octal String Representation
System.out.println("value.toOctalString(i2): " + s);
// It represents Octal string of the given
// integer type i3 argument
s = value.toOctalString(i3);
// Display Octal String Representation
System.out.println("value.toOctalString(i3): " + s);
// It represents Octal string of the given
// integer type i4 argument
s = value.toOctalString(i4);
// Display Octal String Representation
System.out.println("value.toOctalString(i4): " + s);
// It represents Octal string of the given
// integer type i5 argument
s = value.toOctalString(i5);
// Display Octal String Representation
System.out.println("value.toOctalString(i5): " + s);
}
}
Output
輸出量
value.toOctalString(i2): 24
value.toOctalString(i3): 36
value.toOctalString(i4): 17777777777
value.toOctalString(i5): 20000000000
翻譯自: https://www.includehelp.com/java/integer-class-tooctalstring-method-with-example.aspx
tooctalstring