Check out example codes for "rgb to hex java". It will help you in understanding the concepts better.

Code Example 1

int r = 20;
int g = 99;
int b = 155;
String hex = String.format("#%02X%02X%02X", r, g, b);
System.out.println(hex);

//Output #14639B

Learn ReactJs, React Native from akashmittal.com