Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

public class Main {
    /**
     * Transform integer RBG to hex color string
     */
    public static String rgbToHex(int[] color) {
        String colorString = "#";
        for (int element : color) {
            if (element < 16) {
                colorString += "0";
            }
            colorString += Integer.toHexString(element);
        }
        return colorString;
    }
}