> For the complete documentation index, see [llms.txt](https://www.pranaypourkar.co.in/the-programmers-guide/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://www.pranaypourkar.co.in/the-programmers-guide/algorithm/bit-manipulation/number-system/java-program.md).

# Java Program

## Number System Conversion

```java
public class NumberSystemConverter {

    // Decimal to Binary, Octal, Hexadecimal
    public static void decimalToOtherSystems(int decimal) {
        String binary = Integer.toBinaryString(decimal);
        String octal = Integer.toOctalString(decimal);
        String hexadecimal = Integer.toHexString(decimal).toUpperCase();

        System.out.println("Decimal: " + decimal);
        System.out.println("Binary: " + binary);
        System.out.println("Octal: " + octal);
        System.out.println("Hexadecimal: " + hexadecimal);
    }

    // Binary to Decimal, Octal, Hexadecimal
    public static void binaryToOtherSystems(String binary) {
        int decimal = Integer.parseInt(binary, 2);
        int octal = Integer.parseInt(binary, 2);
        String hexadecimal = Integer.toHexString(decimal).toUpperCase();

        System.out.println("Binary: " + binary);
        System.out.println("Decimal: " + decimal);
        System.out.println("Octal: " + Integer.toOctalString(octal));
        System.out.println("Hexadecimal: " + hexadecimal);
    }

    // Octal to Decimal, Binary, Hexadecimal
    public static void octalToOtherSystems(String octal) {
        int decimal = Integer.parseInt(octal, 8);
        String binary = Integer.toBinaryString(decimal);
        String hexadecimal = Integer.toHexString(decimal).toUpperCase();

        System.out.println("Octal: " + octal);
        System.out.println("Decimal: " + decimal);
        System.out.println("Binary: " + binary);
        System.out.println("Hexadecimal: " + hexadecimal);
    }

    // Hexadecimal to Decimal, Binary, Octal
    public static void hexadecimalToOtherSystems(String hexadecimal) {
        int decimal = Integer.parseInt(hexadecimal, 16);
        String binary = Integer.toBinaryString(decimal);
        String octal = Integer.toOctalString(decimal);

        System.out.println("Hexadecimal: " + hexadecimal);
        System.out.println("Decimal: " + decimal);
        System.out.println("Binary: " + binary);
        System.out.println("Octal: " + octal);
    }

    public static void main(String[] args) {
        // Example conversions
        System.out.println("--- Decimal to Binary, Octal, Hexadecimal ---");
        decimalToOtherSystems(26);
        System.out.println();

        System.out.println("--- Binary to Decimal, Octal, Hexadecimal ---");
        binaryToOtherSystems("10110");
        System.out.println();

        System.out.println("--- Octal to Decimal, Binary, Hexadecimal ---");
        octalToOtherSystems("32");
        System.out.println();

        System.out.println("--- Hexadecimal to Decimal, Binary, Octal ---");
        hexadecimalToOtherSystems("1A");
    }
}
```

<figure><img src="https://3632859567-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FPd6ktrA5pPLsZJktj2fm%2Fuploads%2Fgit-blob-a0526dbe517c6f3b5070e9215d7aa3aef161b503%2Fimage.png?alt=media" alt="" width="391"><figcaption></figcaption></figure>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://www.pranaypourkar.co.in/the-programmers-guide/algorithm/bit-manipulation/number-system/java-program.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
