Long.toOctalString() in Java

Long.toOctalString(): This method is available in java.lang.Long class of Java.

Syntax:

String java.lang.Long.toOctalString(long i)

This method takes one argument of type long as its parameter. This method returns a string representation of the long argument as an unsigned integer in base 8.

Parameters: One parameter is required for this method.

i: a long to be converted to a string.

Returns: the string representation of the unsigned long value represented by the argument in octal (base 8).

For Example:

long l = 125

Long.toOctalString(l) = > It returns 175.

Approach

Java

public class LongToOctalString {
    public static void main(String[] args) {

        long l = 125;
        System.out.println(Long.toOctalString(l));

    }
}

Output:

175

No comments:

Post a Comment