I'm still newbie in java I have code but I'm still confused how does it works
so Anyone could explain to me how my code works in converting binary to hexadecimal? I'm a little bit confuse on the nested for loop part so please help me to understand the logic here
heres my code:
import java.io.*;
public class arrays {
    public static void main(String[] args) throws IOException {
        BufferedReader input = new BufferedReader(new InputStreamReader(
                System.in));
        // Binary Storage
        String[] hex = { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A",
                "B", "C", "D", "E", "F" };
        String[] binary = { "0000", "0001", "0010", "0011", "0100", "0101",
                "0110", "0111", "1000", "1001", "1010", "1011", "1100", "1101",
                "1110", "1111" };
        // For User!, input a value:
        System.out.print("Input your Hex Number here : ");
        String userInput = input.readLine();
        String result = "";
        for (int i = 0; i < userInput.length(); i++) {
            /* used for separating the value */
            char temp = userInput.charAt(i);
            String temp2 = "" + temp + "";
            for (int j = 0; j < hex.length; j++) {
                if (temp2.equalsIgnoreCase(hex[j])) {
                    result = result + "\n" + temp + "- " + binary[j];
                }
            }
        }
        //Main output
        System.out.println("THE BINARY OF " + userInput + ":" + result);
    }
}
 
     
    