How to Convert int into octal Integer in Java


This tutorial will help show us how to convert int to octal integer with toOctalString method of Integer wrapper class in Java.

Source Code

package com.beginner.examples;

public class GetOctal {

	public static void main(String[] args) {

		int n = 60;

		// Use the toOctalString() method in the Integer class to get the octal
		// number
		String strOct = Integer.toOctalString(n);

		System.out.println(n + "--Octal number:" + strOct);

	}

}

Output:

60--Octal number:74
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments