I am very new to coding and was presented with this java program that converts a hex number to decimal the line of code I'm having a really hard time grasping is this
val = 16*val + d;
I hope someone can explain to me where does the value for val comes from on the right side of the equation, thank you in advance
/*
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Main.java to edit this template
*/
package javaapplication;
/**
*
* @author Rado
*/
public class JavaApplication {
/**
* @param args the command line arguments
*/
public static void main(String[] args)
{
// TODO code application logic here
String digits = "0123456789ABCDEF";
String myhex="ABC";
int val = 0;
for (int i = 0; i < myhex.length(); i++)
{
char c = myhex.charAt(i);
int d = digits.indexOf(c);
val = 16*val + d;
}
System.out.println(val);
}
}