- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Java lang Long.toOctalString() Method with Examples
The java.lang.Long.toOctalString() method returns a string representation of the long argument as an unsigned integer in base 8.
Example
Let us now see an example −
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)); } }
Output
Number = 220 Octal = 334
Example
Let us now see another example wherein negative number is considered −
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)); } }
Output
Number = -55 Octal = 1777777777777777777711
- Related Articles
- Java lang Integer.toHexString() Method with Examples
- Java signum() method with Examples
- Java lang.Long.toBinaryString() method with Examples
- Java cbrt() method with Examples
- Java ceil() method with Examples
- Java sqrt() method with Examples
- Java floor() method with Examples
- Java toDegrees() method with Examples
- Java Signature getAlgorithm() method with Examples
- Java Signature getInstance() method with Examples
- Java Signature getProvider() method with Examples
- Java Signature initSign() method with Examples
- Java Signature toString() method with Examples
- Java streams counting() method with examples
- MatchResult start() method in Java with examples.

Advertisements