Check out example codes for "binary to octal conversion java program". It will help you in understanding the concepts better.

Code Example 1

// conversion of binary to octal in java..
public class Main{
    public static void main(String args[]) throws Exception{
        String binary = "1100100";                // binary number.. 
        int decimal = Integer.parseInt(binary,2); // converting binary to decimal
        System.out.println(Integer.toOctalString(decimal)); // 144 <= octal output..  

Learn ReactJs, React Native from